自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(64)
  • 收藏
  • 关注

原创 Java语言程序设计 例题3.17(游戏:石头剪刀布)

*3.17 (Game: scissor, rock, paper) Write a program that plays the popular scissor-rockpapergame. (A scissor can cut a paper, a rock can knock a scissor, and a paper canwrap a rock.) The program randomly generates a number 0, 1, or 2 representingscisso..

2022-05-17 00:33:18 961 2

原创 Java语言程序设计 例题3.15

**3.15 (Game: lottery) Revise Listing 3.8, Lottery.java, to generate a lottery of a threedigitnumber. The program prompts the user to enter a three-digit number anddetermines whether the user wins according to the following rules:1. If the user input m.

2022-05-16 23:45:22 184

原创 Java语言程序设计 例题5.5(从公斤到磅和从磅到公斤的转换)

5.5 (Conversion from kilograms to pounds and pounds to kilograms) Write a programthat displays the following two tables side by side:Kilograms Pounds | Pounds Kilograms1 2.2 | 20 9.093 6.6 | 25 11.36...197 433.4 | 510 231.82199 437.8 | 515 234.095

2022-05-16 23:12:41 728

原创 Java语言程序设计 例题5.11(寻找能被5或6整除,但不能被同时整除的数)

5.11 (Find numbers divisible by 5 or 6, but not both) Write a program that displaysall the numbers from 100 to 200, ten per line, that are divisible by 5 or 6, but notboth. Numbers are separated by exactly one space.5.11(寻找能被5或6整除,但不能被同时整除的数)编写一个程序,显..

2022-05-16 20:42:15 1258

原创 Java语言程序设计 例题5.4(英里和公里的转化)

5.4 (Conversion from miles to kilometers) Write a program that displays the followingtable (note that 1 mile is 1.609 kilometers):Miles Kilometers1 1.6092 3.218...9 14.48110 16.0905.4(英里和公里的转化)写一个程序显示下表(注意1公里等于1.609公里):Miles Kilometers1 1.6092

2022-05-16 19:19:40 1300

原创 Java语言程序设计 例题3.14

3.14(Game:headsortails)Writeaprogramthatletstheuserguesswhethertheflipofacoinresultsinheadsortails.Theprogramrandomlygeneratesaninteger0or1,whichrepresentsheadortail.Theprogrampromptstheusertoenteraguessand...

2022-05-16 00:30:10 158

原创 Java语言程序设计 例题3.13(计算税款)

*3.13(Financialapplication:computetaxes)Listing3.5,ComputeTax.java,givesthesourcecodetocomputetaxesforsinglefilers.CompleteListing3.5tocomputethetaxesforallfilingstatuses.*3.13(金融应用:计算税款)清单3.5给出了为单个申报者计算税收的源代码.完成清单3.5来计算所有...

2022-05-16 00:11:12 491

原创 Java语言程序设计 例题3.12(回文数)

3.12(Palindromenumber)Writeaprogramthatpromptstheusertoenterathree-digitintegeranddetermineswhetheritisapalindromenumber.Anumberispalindromeifitreadsthesamefromrighttoleftandfromlefttoright.Hereisasamplerunof...

2022-05-15 23:39:56 1227

原创 Java语言程序设计 例题3.10(游戏:加法检测)

3.10(Game:additionquiz)Listing3.3,SubtractionQuiz.java,randomlygeneratesasubtraction question.Revisetheprogramtorandomlygenerateanadditionquestionwithtwointegers lessthan100.3.10(游戏:加法检测)清单3.3随机产生一个减法问题.修改程序,随机生成两个小于100的整数的加法问...

2022-05-15 23:18:57 308

原创 Java语言程序设计 例题3.9(检验ISBN)

**3.9(Business:checkISBN-10)AnISBN-10(InternationalStandardBookNumber)consistsof10digits:d1d2d3d4d5d6d7d8d9d10.Thelastdigit,d10,isachecksum,whichiscalculatedfromtheotherninedigitsusingthefollowingformula:(d1*1+d2*2...

2022-05-15 22:55:03 797

原创 Java语言程序设计 例题3.8(对三个整数排序)

(Sort three integers)Write a program that prompts the user to enter three integers and display the integers in non-decreasing srder.(对三个整数排序)编写一个程序,提示用户输入三个整数,并按非递减顺序显示.代码如下(这种做法第一种很冗余,我进行学习后再优化)import java.util.Scanner;public class Unite3Test8D {

2022-05-15 12:23:33 646

原创 Java语言程序设计 例题3.7(金融应用程序:货币单位)

(Financial application :monetary unites)Modify Listing 2.10,ComputeChange.java,to display the nonzero denominations only,using singular words for single units such as 1dollar and 1penny,and plural words for more than one unite such as 2dollars and 3 pennie

2022-05-15 10:32:01 312

原创 Java语言程序设计 一维数组的使用:读入学生成绩,找出最高分,输出等级

代码如下:import java.util.Scanner;public class shuzu { public static void main(String[] args) { Scanner scan=new Scanner(System.in) ; System.out.println("请输入学生人数:"); int num=scan.nextInt(); int arr[]=new int[num];//定义数组 int a=0; System.ou...

2022-05-15 00:47:03 1967

原创 Java 循环嵌套问题三:100以内质数的输出以及优化(笔试题)

质数是只有一和它本身才能被除尽的一类数,输出100以内的质数本质还是循环嵌套首先,外层循环遍历100以内的自然数,因为1不是质数,所以从2开始,内层循环从1开始到自己本身结束,每个数都被i除一次,这里我们反其道而行之,我们先定义一个布尔类型的变量isFlag赋值为true,如果在内层循环的时候 i 除以 j 的时候出现了i%j==0的情况也就是出现了除了 i 自己和1以外其他的约数,就给isFlag赋值false,相当于贴了一个标签,说明当此循环的i不是质数。然后我们在接下来的判断过程中,当isFlag

2022-05-14 11:29:52 504

原创 Java 循环嵌套问题二:打印九九乘法表

打印九九乘法表:用for循环打印99乘法表,和问题一里面的思路一样,还是使用循环嵌套,外层决定有多少行,内层决定一行有多少个式子代码如下:public class chengfabiao { public static void main(String[] args) { for(int i=1;i<=9;i++) { for(int j=1;j<=i;j++) { System.out.print(i+"*"+j+"="+(i*j)); S

2022-05-14 01:11:04 929

原创 Java 循环嵌套问题一:打印菱形

用Java编写一个如下的菱形:本质问题就是循环嵌套,外层决定有多少行,内层决定每行有多少*,而且内层需要分成上下两个大部分,上下每个部分要分成四个部分:前面空白,前面*,后面*,后面空白四个部分代码如下public class lingxing { public static void main(String[] args)//本质是循环嵌套,将一个菱形分成多个部分 { for(int i=1;i<=9;i++) //先写菱形的上半部分,外层决定有多少行 { .

2022-05-13 19:22:26 684 1

原创 Java语言程序设计 例题3.6(健康指标:BMI)

*3.6(Healthapplication:BMI)ReviseListing3.4,ComputeAndInterpretBMI,java,tolettheuserenterweight,feet,andinches.Forexample,ifapersonis5feetand10inches,youwillenter5forfeetand10forinches.Hereisasamplerun:Enterweighti...

2022-05-13 18:19:28 564

原创 Java语言程序设计 例题3.5(给出未来的日期)

*3.5(Find future dates)Write a program that prompts the user to enter an integer for today's day of the week(Sunday is 0,Monday is 1,...,and Saturday is 6).Also prompt the user to enter the number of days after today for a future day and display the future

2022-05-13 17:32:16 539

原创 Java语言程序设计 例题3.4 (调取随机月份)

**3.4(Random month)Write a program that randomly generates an integer between 1 and 12 and displays the English month name January,February,...,December for the number 1,2,3,...,12,accordingly.**3.4(随机月份)编写一个程序,随机生成1到12之间的整数,并显示英文月份名称January,February,...

2022-05-12 23:37:33 237

原创 Java语言程序设计 例题 3.3(解2×2线性方程)

*3.3(Algebra:solve 2×2linear equations)A linear equation can be solved using Crame's rule given in Programming Exercise 1.13 .Write a program that prompts the user to enter a,b,c,d,e,and,f and displays the result. If ad- bc is 0,report that "The equation h

2022-05-12 20:57:48 230

原创 Java语言程序设计 例题3.2(游戏:将三个数相加)

*3.2(Game: add three numbers) The program in Listing 3.1, AdditionQuiz.java, generates two integers and prompts the user to enter the summation of these two integers. Revise the program to generate three single-digit integers and prompt the user to en...

2022-05-11 23:42:01 548

原创 Java语言程序设计 例题3.1(代数:解一元二次方程)

*3.1(Algebra:solvequadraticeuations)Thetworootsofaquadratic equation ax^2+bx+c=0 can be obtain using the following formula:b^2➖4aciscalledthediscriminantofthequadraticequation.Ifitispositive,theequationhastworealroots.Ifitisz...

2022-05-11 20:54:23 451

原创 Java语言程序设计 例题3.11(查找一个月的天数)

*3.11(Find the number of days in a month) Write a program that prompts the user to enter the month and year and displays the number of days in the month. For example, if the user entered month 2 and year 2012, the program should display that February 2012

2022-05-10 23:07:44 833 2

原创 HCIA的学习

1876年----贝尔获得电话专利----公共交换电话网:核心技术为电路交换----1888年。传输介质:RJ-45双绞线(网线)----由8根铜丝(导电性好)构成,分成四组,两两相绞()2.目的:资源共享--- ①信息资源的共享:联网的计算机用户之间可以互相通信,数据的存储。将抽象语言---转换成---电信号 :Ⅰ抽象语言---编码 应用层。(云技术---①云计算---分布式计算(多个计算机共同工作)Ⅲ二进制---电信号 介质(硬件)访问控制层。1946年----第一台电子计算机。

2023-06-26 14:44:07 417

原创 暴力破解———罗马数字逆向解法,猜年龄利用位数信息,罗马数字的枚举解法

暴力破解

2022-07-17 09:43:51 651 1

原创 Java语言程序设计 例题9.10(代数:二次方程式)

*9.10 (Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation ax2 + bx + x = 0. The class contains: ■ Private data fields a, b, and c that represent three coefficients. ■ A constructor for the arguments for a, b, and

2022-06-13 22:23:04 848

原创 Java语言程序 例题9.6(秒表)

*9.6 (Stopwatch) Design a class named StopWatch. The class contains: ■ Private data fields startTime and endTime with getter methods. ■ A no-arg constructor that initializes startTime with the current time. ■ A method named start() that resets the startTim

2022-06-13 21:44:00 1471

原创 Java语言程序设计 7.26(完全相同的数组)

7.26 (Strictly identical arrays) The arrays list1 and list2 are strictly identicalif their corresponding elements are equal. Write a method that returns true if list1 and list2 are strictly identical, using the following header:public static boolean equals

2022-06-13 19:09:10 326

原创 Java语言程序设计 例题7.7(计算单个数字)

*7.7 (Count single digits) Write a program that generates 100 random integers between 0 and 9 and displays the count for each number. (Hint: Use an array of ten integers, say counts, to store the counts for the number of 0s, 1s, . . . , 9s.)*7.7(计算单个数字)编写一

2022-06-13 18:25:10 266

原创 Java语言程序设计 例题6.20(计算字符串中的字母数)

*6.20 (Count the letters in a string) Write a method that counts the number of letters in a string using the following header:public static int countLetters(String s)Write a test program that prompts the user to enter a string and displays the numberof let

2022-06-13 18:05:00 898

原创 Java语言程序设计 例题6.8(摄氏度和华氏度的转换)

6.8 (Conversions between Celsius and Fahrenheit) Write a class that contains the followingtwo methods:/** Convert from Celsius to Fahrenheit */public static double celsiusToFahrenheit(double celsius)/** Convert from Fahrenheit to Celsius */public static do

2022-06-13 17:38:22 1707 1

原创 Java语言程序设计 例题6.5(将三个数排序)

*6.5 (Sort three numbers) Write a method with the following header to display three numbers in increasing order:public static void displaySortedNumbers(double num1, double num2, double num3)Write a test program that prompts the user to enter three numbers

2022-06-13 17:04:33 1012

原创 Java语言程序设计 例题5.27(显示闰年)

**5.27 (Display leap years) Write a program that displays all the leap years, ten per line, from 101 to 2100, separated by exactly one space. Also display the number of leap years in this period.**5.27(显示闰年)编写一个程序,显示从101到2100的所有闰年,每行10个,用一个空格隔开。还显示此期间的闰年数。

2022-06-13 16:36:42 331

原创 Java语言程序设计 例题5.15(显示ASCII字符表)5.24(数列求和)

*5.15 (Display the ASCII character table) Write a program that prints the characters in the ASCII character table from ! to ~. Display ten characters per line. The ASCII table is shown in Appendix B. Characters are separated by exactly one space.5.15(显示ASC

2022-06-13 16:22:33 249

原创 Java语言程序设计 例题13.6(ComparableCircle类)例题13.7()

*13.6 (The ComparableCircle class) Define a class named ComparableCirclethat extends Circle and implements Comparable. Draw the UML diagram and implement the compareTo method to compare the circles on the basis of area. Write a test class to find the large

2022-06-08 10:21:25 1388

原创 Java语言程序设计 类和对象(包装类的使用)

一、包装类1.包装类顾名思义就是将对象包装成类,使它具有类的功能,使剧本数据类型变成面向对象的类型2..基本数据类型byte, short, int, long, float, double, char, boolean,对应的包装类分别是Byte, Short, Integer, Long, Float, Double, Character, Boolean3.包装类--->基本数据类型:拆箱4.基本数据类型--->包装类:装箱例如:5. 自动拆箱、装箱自动拆箱、装箱是从JDK1.5开始才有的特性,其实

2022-06-04 23:12:19 130

原创 Java语言程序设计 类和对象(抽象类与抽象方法、代码块)

一、抽象类:1.随着继承层次中一个个新子类的定义,类变得越来越具体,而父类则更一般,更通用。类的设计应该保持父类和子类能够共享特征,有时将一个父类设计的非常抽象,以至于它没有具体的实例,这样的类叫做抽象类2.关键字 abstract abstract:抽象的 abstract可以用来修饰的结构:类、方法 3.abstract修饰类:抽象类 >当我们用abstract修饰类时,此类不能实例化 >抽象类中一定有构造器,便于子类对象实例化的时候调用

2022-06-04 22:26:38 156

原创 Java语言程序设计 类和对象(单例设计模式)

一、单例设计模式:1.所谓类的单例设计模式,就是采取一定的方法保证在整个的软件系统中,对某个类只能存在一个对象实例2.如何实现:2.1.私有化类的构造器(避免外部调用Bank的构造器)2.2内部创建类的对象2.3.提供公共的方法,返回类的对象2.4.要求此对象也必须是静态的 3.区分饿汉式和懒汉式 饿汉式: 好处:线程安全 坏处:对象的加载时间过长 懒汉式: 好处:延迟对象的创建 坏处:目前的

2022-06-04 22:03:44 162

原创 Java语言程序设计 类和对象(Objcet类)

一、Objcect类1.Object类是所有java类的根父类2.如果在类的声明中未使用extends关键字指明其父类,则默认父类为Java.lang.Object3.Objcet类中的功能(属性方法)有通用性4.Object类只声明了一个空参构造器5.==运算符与equals()的区别==运算符:5. 1.可以用在基本数据类型变量和引用数据类型变量中5.2.如果比较的是基本数据类型变量,比较两个变量保存的数据是否相等如果比较的是引用数据类型变量,比较两个变量保存的地址值是否相等6 equals()的用法6

2022-06-04 21:45:54 212

原创 Java语言程序设计 类和对象的练习(类的数组的建立以及相关问题)

计算平均分:使用成员变量、成员方法、构造方法、和this关键字,先记录4名学生的语文、数学、英语这三科成绩,再计算每个人的平均分。运行结果如下: 代码如下:结果如下: 这里要注意!!!!!如果Student[] Student =new Student[4];创建类的数组的时候不添加for(int i = 0;i

2022-06-01 21:52:06 513

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除