《Java语言程序设计:基础篇》课后复习题答案-第二章

合集下载

java语言程序设计基础篇 复习题答案

java语言程序设计基础篇 复习题答案

java语言程序设计基础篇复习题答案Java语言程序设计基础篇复习题答案Java语言是一种广泛应用于软件开发领域的高级编程语言,具有跨平台、面向对象、简单易学等特点。

在学习Java语言的过程中,复习题是一种非常有效的巩固知识的方式。

本文将为大家提供一些Java语言程序设计基础篇的复习题答案,希望能够帮助大家更好地理解和掌握Java语言。

1. 以下代码的输出结果是什么?```javapublic class Test {public static void main(String[] args) {int x = 5;int y = 10;System.out.println("x + y = " + (x + y));System.out.println("x - y = " + (x - y));System.out.println("x * y = " + (x * y));System.out.println("x / y = " + (x / y));}}```答案:```x + y = 15x - y = -5x * y = 50x / y = 0```2. 以下代码的输出结果是什么?```javapublic class Test {public static void main(String[] args) { int x = 5;int y = 10;boolean result = (x > y) && (x != y); System.out.println(result);}}```答案:```false```3. 以下代码的输出结果是什么?```javapublic class Test {public static void main(String[] args) {int x = 5;int y = 10;boolean result = (x < y) || (x == y);System.out.println(result);}}```答案:```true```4. 以下代码的输出结果是什么?```javapublic class Test {public static void main(String[] args) {int x = 5;int y = 10;if (x > y) {System.out.println("x is greater than y"); } else if (x < y) {System.out.println("x is less than y");} else {System.out.println("x is equal to y");}}}```答案:```x is less than y```5. 以下代码的输出结果是什么?```javapublic class Test {public static void main(String[] args) {int x = 5;int y = 10;int max = (x > y) ? x : y;System.out.println("The maximum value is: " + max); }}```答案:```The maximum value is: 10```通过以上复习题的答案,我们可以看到Java语言程序设计基础篇中的一些基本概念和语法。

Java程序设计课后练习答案

Java程序设计课后练习答案

《J a v a程序设计》课后练习答案第一章Java概述一、选择题1.( A )是在Dos命令提示符下编译Java程序的命令,( B )是运行Java程序的命令。

A.javacB.javaC.javadocD.javaw2.( D )不是Java程序中有效的注释符号。

A.//B.C.D.3.(A.B.C.D.4.JavaA.B.C.D.5.JavaA.1、JavaJava(JVM)Java以下图展示了Java程序从编译到最后运行的完整过程。

2、简述Java语言的特点Java具有以下特点:1)、简单性Java语言的语法规则和C语言非常相似,只有很少一部分不同于C语言,并且Java还舍弃了C语言中复杂的数据类型(如:指针和结构体),因此很容易入门和掌握。

2)、可靠性和安全性Java从源代码到最终运行经历了一次编译和一次解释,每次都有进行检查,比其它只进行一次编译检查的编程语言具有更高的可靠性和安全性。

3)、面向对象Java是一种完全面向的编程语言,因此它具有面向对象编程语言都拥有的封装、继承和多态三大特点。

4)、平台无关和解释执行Java语言的一个非常重要的特点就是平台无关性。

它是指用Java编写的应用程序编译后不用修改就可在不同的操作系统平台上运行。

Java之所以能平台无关,主要是依靠Java虚拟机(JVM)来实现的。

Java编译器将Java源代码文件编译后生成字节码文件(一种与操作系统无关的二进制文件)5)、6)、Java来。

1、/****/}}第二章Java语法基础一、选择题1.下面哪个单词是Java语言的关键字( B )?A. DoubleB. thisC. stringD. bool2.下面属于Java关键字的是( D )。

A. NULLB. IFC. DoD. goto3.在启动Java应用程序时可以通过main( )方法一次性地传递多个参数。

如果传递的参数有多个,可以用空格将这些参数分割;如果某一个参数本身包含空格,可以使用( B )把整个参数引起来。

java程序设计课后第二章习题程序答案

java程序设计课后第二章习题程序答案

public class xiti9{public static void main(String args[]) {int x=4;int y;if(x<1){y=x;}else if(x>=10){y=4*x;}else{y=3*x-2;}System.out.println("y="+y);}}习题12public class xiti12{public static void main(String args[]) {int sum=0;for(int k=1;k<=10;k++){sum=sum+k*k;}System.out.println("sum="+sum); }}习题13public class xiti13{public static void main(String args[]) {intt,a=3,b=5,c=8;if(a<b){t=a;a=b;b=t;}if(a<c){t=a;a=c;c=t;}{t=b;b=c;c=t;}System.out.println("大小顺序输出为:"+a+" "+b+" "+c); }}习题14public class xiti14{public static void main(String args[]){int n=1;System.out.print("\n1-100之间的所有素数为:\n"+" 3"); for(int i=1;i<=100;i++){for(int j=2;j<=i/2;j++){if(i%j==0){break;}if(j==i/2){System.out.print(" "+i);n++;}}}System.out.println("\n共有"+n+"个素数。

Java语言程序设计(基础篇)原书第十一版-梁勇-第2-3章-课后题答案

Java语言程序设计(基础篇)原书第十一版-梁勇-第2-3章-课后题答案

2.5编写程序,读入英尺数,将其转换成米数并显示结果package pro0904;import java.util.Scanner;public class Feet {public static void main(String[] args) {Scanner in=new Scanner(System.in);System.out.print("请输入英尺数:");double feet=in.nextDouble();System.out.print(feet+"英尺是"+0.305*feet+"米");}}2.10编写程序,计算将水从初始温度加热到最终温度所需要的能量。

应提示用户输入水的重量,以及水的初始温度和最终温度package pro0904;import java.util.Scanner;public class Energy {public static void main(String[] args) {Scanner in=new Scanner(System.in);System.out.print("请输入水的重量(kg):");double m=in.nextDouble();System.out.print("请输入初始温度:");double t1=in.nextDouble();System.out.print("请输入最终温度:");double t2=in.nextDouble();System.out.print("所需的能量为"+m*(t2-t1)*4184);}}2.13假设你每月向银行账户存100美元,年利率为5%,那么每月利率是0.05/12=0.00417。

编写程序显示六个月后账户上的钱数package pro0904;import java.util.Scanner;public class Money {public static void main(String[] args) {Scanner in=new Scanner(System.in);System.out.print("请输入存取月份:");int month=in.nextInt();double money=0;for (int i=0;i<month;i++){money+=100;money=money*1.00417;System.out.println(money);}System.out.print("六个月后账户上的钱数为"+money);}}2.15编写程序提示用户输入体重(磅为单位),以及身高(英寸为单位),然后显示BMI。

JAVA课后答案第二章

JAVA课后答案第二章

第2章1.Java语言有哪些主要特点。

平台独立性安全性多线程网络化面向对象2.目前美国Sun公司提供的适用不同开发规模的JDK有哪些。

目前Sun共提供了三种不同的版本:微平台版J2ME(Java 2 Platform Micro Edition),标准版J2SE(Java 2 Platform Standard Edition)和企业版J2EE(Java 2 Platform Enterprise Edition),这三种版本分别适用于不同的开发规模和类型,对于普通Java开发人员和一般学习者来说,选用标准版J2SE就可以了,学会了J2SE,再学J2ME或J2EE就比较容易上手,因为它们之间虽有所侧重,但相似之处很多,尤其是语言本身是一样的,都是Java。

3.Java Application的开发步骤有哪些。

Java Application的开发步骤:(1)下载JDK软件并安装;(2)配置相应的环境变量(path和classpath);(3)编写Java源程序(文本编辑器或集成开发环境IDE);(4)编译Java源程序,得到字节码文件(javac *.java);(5)执行字节码文件(java 字节码文件名)。

4.什么是环境变量,设置环境变量的主要目的是什么。

环境变量的配置主要是为了进行“寻径”,也即让程序能找到它需要的文件,所以设置的内容就是一些路径。

5.不参考书本,试着编写一个简单的Java Application程序,实现在Dos窗口输出“Welcome to Nanjing City!”字符串。

并对该程序进行编译和运行。

public class Hello {public static void main(String args[]){System.out.println("Welcome to Nanjing City!");}}6.编写一个Java Application程序,实现分行显示字符串“Welcome to Nanjing City”中的四个单词。

JAVA语言程序设计(基础篇)答案

JAVA语言程序设计(基础篇)答案

3.4import javax.swing.*;public class AdditionTutor{public static void main(String[] args){int number1=(int)(System.currentTimeMillis()%100);int number2=(int)(System.currentTimeMillis()*5%100);String answerString=JOptionPane.showInputDialog("what is "+ number1 +"+ "+ number2+" ?");int answer=Integer.parseInt(answerString);JOptionPane.showMessageDialog(null,number1 +" + "+ number2 +" = "+answer+" is "+(number1+number2==answer));}}3.10import javax.swing.JOptionPane;public class ComputeTaxWithSelectionStatement{public static void main(String[] args){//Prompt the user to enter filing statusString statusString = JOptionPane.showInputDialog("Enter the filing status:\n"+"(0-single filer,1-married jointly,\n"+"2-married separately,3-head of household)");int status = Integer.parseInt(statusString);//Prompt the user to enter taxable incomeString incomeString = JOptionPane.showInputDialog("Enter the taxable income:");double income = Double.parseDouble(incomeString);//Comput taxdouble tax=0;if (status == 0){//Compute tax for single filersif (income <= 6000)tax = income * 0.10;else if (income <= 27950)tax = 6000 * 0.10 + (income - 6000) * 0.15;else if (income <= 67700)tax = 6000 * 0.10 + (27950 - 6000) * 0.15 +(income - 27950) * 0.27;else if (income <= 141250)tax = 6000 * 0.10 + (27950 - 6000) * 0.15 +(67700 - 27950) * 0.27 + (income - 67700) * 0.30;else if (income <=307050)tax = 6000 * 0.10 + (27950 - 6000) * 0.15 +(67700 - 27950) * 0.27 + (141250 - 67700) * 0.30 +(income - 141250) * 0.35;elsetax = 6000 * 0.10 + (27950 - 6000) * 0.15 +(67700 - 27950) * 0.27 + (141250 -67700) * 0.30 +(307050 - 141250) * 0.35 + (income - 307050) * 0.386;}else if (status == 1){//Compute tax for married file jointly if (income <= 12000)tax = income * 0.10;else if (income <= 46700)tax = 12000 * 0.10 + (income - 12000) * 0.15;else if (income <= 112850)tax = 12000 * 0.10 + (46700 - 12000) * 0.15 +(income - 46700) * 0.27;else if (income <= 171950)tax = 12000 * 0.10 + (46700 - 12000) * 0.15 +(112850 - 46700) * 0.27 + (income - 112850) * 0.30;else if (income <= 307050)tax = 12000 * 0.10 + (46700 - 12000) * 0.15 +(112850 - 46700) * 0.27 + (141250 - 112850) * 0.30 +(income - 307050) * 0.35;elsetax = 12000 * 0.10 + (46700 - 12000) * 0.15 +(112850 - 46700 ) * 0.27 + (171950 - 112850) * 0.30 +(307050 - 171950) * 0.35 + (income - 307050) * 0.386;}else if (status == 2){//Compute tax for married separately if (income <= 6000)tax = income * 0.10;else if (income <= 23350)tax = 6000 * 0.10 + (income - 6000) * 0.15;else if (income <= 56425)tax = 6000 * 0.10 + (23350 - 6000) * 0.15 +(income - 23350) * 0.27;else if (income <= 85975)tax = 6000 * 0.10 + (23350 - 6000) * 0.15 +(56425 - 23350) * 0.27 + (income - 56425) * 0.30;else if (income <= 153525)tax = 6000 * 0.10 + (23350 - 6000) * 0.15 +(56425 - 23350) * 0.27 + (85975 - 56425) * 0.30 +(income - 85975) * 0.35;elsetax = 6000 * 0.10 + (23350 - 6000) * 0.15 +(56425 - 23350) * 0.27 + (85975 - 56425) * 0.30 +(153525 - 85975) * 0.35 + (income - 153525) * 0.386;}else if (status == 3){//Compute tax for head of householdif (income <= 10000)tax = income * 0.10;else if (income <= 37450)tax = 10000 * 0.10 + (income - 10000) * 0.15;else if (income <= 96700)tax = 10000 * 0.10 + (37450 - 10000) * 0.15 +(income - 37450) * 0.27;else if (income <= 156600)tax = 10000 * 0.10 + (37450 - 10000) * 0.15 +(96700 - 37450) * 0.27 + (income - 96700) * 0.30;else if (income <= 307050)tax = 10000 * 0.10 + (37450 - 10000) * 0.15 +(96700 - 37450) * 0.27 + (156600 - 96700) * 0.30 +(income - 156600) * 0.35;elsetax = 10000 * 0.10 + (37450 - 10000) * 0.15 +(96700 - 37450) * 0.27 + (156600 - 96700) * 0.30 +(307050 - 156600) * 0.35 + (income - 307050) * 0.386;}else{System.out.println("Error: invalid status");System.exit(0);}//Display the resultJOptionPane.showMessageDialog(null,"Tax is " +(int)(tax * 100) / 100.0);}}4.11public class ZhengChu{public static void main(String[] args){int count=0;for(int i=100;i<=200;i++){if((i%5==0||i%6==0)&&i%30!=0){System.out.print(" "+ i);count++;if(count%10==0)System.out.println();}}}}4.14public class ASCII{public static void main(String[] args){int count = 0;for(int i = 33; i <= 126; i++){count++;char ch = (char)i;System.out.print(" " + ch);if(count % 10 == 0)System.out.println();}}}4.17import javax.swing.JOptionPane;public class FindSalesAmount{/**Main method*/public static void main(String[] args){//The commission soughtString COMMISSION_SOUGHTString = JOptionPane.showInputDialog("Enter the COMMISSION_SOUGHT :");double COMMISSION_SOUGHT = Double.parseDouble(COMMISSION_SOUGHTString);double commission = 0;double salesAmount;for (salesAmount = 0.01;commission <= COMMISSION_SOUGHT;){salesAmount += 0.01; //防止犯off-by-one错误,先判断在做自加!if (salesAmount >= 10000.01)commission =5000 * 0.08 + 5000 * 0.1 + (salesAmount - 10000) * 0.12;else if (salesAmount >= 5000.01)commission = 5000 * 0.08 + (salesAmount - 5000) * 0.10;elsecommission = salesAmount * 0.08;}String output ="The sales amount $" + (int)(salesAmount * 100) / 100.0 +"\n is needed to make a commission of $" + COMMISSION_SOUGHT;JOptionPane.showMessageDialog(null,output);}}5.6import javax.swing.JOptionPane;public class PrintPyramid{public static void main(String[] args){String input = JOptionPane.showInputDialog("Enter the number of lines:");int numberOfLines = Integer.parseInt(input);displayPattern(numberOfLines);}public static void displayPattern(int n){for (int row = 1;row <= n;row++){for (int column = 1;column <= n - row;column++)System.out.print(" ");for (int num = row;num >= 1;num--)System.out.print((num >= 10) ? " " + num : " " + num);System.out.println();}}}5.18public class MathSuanFa{public static void main(String[] args){double A = Math.sqrt(4);double B = (int)Math.sin(2 * Math.PI);double C = (int)Math.cos(2 * Math.PI);double D = (int)Math.pow(2, 2);double E = (int)Math.log(Math.E);double F = (int)(Math.exp(1)*100000)/100000.0;double G = (int)Math.max(2, Math.min(3, 4));double H = (int)Math.rint(-2.5);double I = (int)Math.ceil(-2.5);double J = (int)Math.floor(-2.5);int K = (int)Math.round(-2.5f);int L = (int)Math.round(-2.5);double M = (int)Math.rint(2.5);double N = (int)Math.ceil(2.5);double O = (int)Math.floor(2.5);int P = (int)Math.round(2.5f);int Q = (int)Math.round(2.5);int R = (int)Math.round(Math.abs(-2.5));System.out.println(A +" "+ B +" "+ C +" "+ D +" "+ E +" "+ F +" "+ G +" "+ H +" "+ I +" "+ J +" "+ K +" "+ L +" "+ M +" "+ N +" "+ O +" "+ P +" "+ Q +" "+ R);}}6.9import javax.swing.JOptionPane;public class Array{public static void main (String[] args){String incomeString = JOptionPane.showInputDialog("Enter the number of array size:");int income = Integer.parseInt(incomeString);int arraySize = income;int [] myList = new int [arraySize];int m;for ( m = 0; m < arraySize; m++){String elementString = JOptionPane.showInputDialog("Enter the " + (m + 1) + " element of the array");int element = Integer.parseInt(elementString);myList[m] = element;}int minElement = myList[0];for (int i=1; i < arraySize; i++){if (myList[i] < minElement)minElement = myList[i];}JOptionPane.showMessageDialog(null,"The min element is: " + minElement); }}。

Java语言程序设计 课后习题+答案

Java语言程序设计 课后习题+答案

第一章课后习题1.编译Java程序的命令是什么?2.执行Java程序的命令是什么?3.Java应用程序和小程序的区别是什么?4.编写一个application ,实现在屏幕上打印自己名字的功能。

第一章课后习题答案1.编译Java程序的命令是什么?答案:javac 源文件名2.执行Java程序的命令是什么?java 主类名3.Java应用程序和小程序的区别是什么?Java application⏹由Java解释器独立运行字节码⏹由专门的命令行启动程序执行⏹程序中有定义了main()方法的主类Java applet⏹不能独立运行,字节码必须嵌入HTML文档⏹当浏览器调用含applet的Web页面时执行⏹程序中含有java. applet. Applet 类的子类4.编写一个application ,实现在屏幕上打印自己名字的功能。

class Test{public static void main(String[] args){System.out.println(“张三”);}}第二章课后习题(1)一、选择题1.下列变量定义错误的是。

A) int a; B) double b=4.5; C) boolean b=true; D)float f=9.8;2.下列数据类型的精度由高到低的顺序是:a)float,double,int,longb)double,float,int,bytec)byte,long,double,floatd)double,int,float,long3.执行完下列代码后,int a=3;char b='5';char c=(char)(a+b);c的值是?A)’8’ b)53 c)8 d)564.Unicode是一种_____________A) 数据类型 B)java包 C)字符编码 D)java类5.6+5%3+2的值是___________A)2 B)1 C) 9 D)106.下面的逻辑表达式中合法的是__________A)(7+8)&&(9-5) B)(9*5)||(9*7) C)9>6&&8<10 D)(9%4)&&(8*3) 7.java语言中,占用32位存储空间的是__________。

Java程序设计 第2章习题参考答案[2页]

Java程序设计 第2章习题参考答案[2页]

第2章习题参考答案一、简答题1.运行Java程序需要哪些软件?至少需要2个软件:(1)JDK。

(2)开发平台,如Eclipse、MyEclipse、Jcreate、IntelliJ IDEA等。

2.JDK与Eclipse有什么关系?JDK是Java软件开发工具包,是整个java开发的核心,它包含了JAVA的运行环境JRE和JVM。

Eclipse是一个集成开发平台,其运行依赖于jdk和jre。

3.Java程序分为哪几类?有什么区别?主要是2类:(1)Application,即Java应用程序,是可以独立运行的Java程序,由Java解释器控制执行,也是最常见的类型。

(2)Applet,即Java小程序,不能独立运行,需嵌入到Web页,由Java兼容浏览器控制执行。

4.如何在Eclipse环境下运行Java程序?搭建Java开发环境,安装JDK,配置环境变量,并安装eclipse,搭建完成打开并建Java项目,点击File——New——Java Project,输入需要创建的项目名,创建完成后点击功能下面src文件夹。

点击New——Class,在对话框输入类名,注意名称要与项目名称一致,点击完成编写代码,保存源文件,点击“执行”按钮,即可运行。

二、操作题3.依照本章例题,自己分别编写一个Application和Applet,功能是输出以下信息并在Eclipse环境下运行。

I love Java!应用程序:public class ILoveJava {public static void main (String args[ ]){System.out.println("I love Java!");}}小程序:import java.awt.*;import java.applet.*;public class HelloWorldApplet extends Applet {public void paint(Graphics g){g.drawString ("I love Java !",20,20); }}。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Chapter2Elementary Programming1.Valid identifiers:applet,Applet,$4,apps,x,y,radiusInvalid identifiers:a++,--a,4#R,#44,class,public, intKeywords:class,public,int2.double miles=100;final double KILOMETERS_PER_MILE= 1.609;double kilometers=KILOMETERS_PER_MILE*miles;System.out.println(kilometers);The value of kilometers is160.9.3.There are three benefits of using constants:(1)you don’t have to repeatedly type the same value;(2)the value can be changed in a single location,ifnecessary;(3)the program is easy to read.final int SIZE=20;4.a=46/9;=>a=5a=46%9+4*4-2;=>a=1+16–2=15a=45+43%5*(23*3%2);=>a=45+3*(1)=48a%=3/a+3;=>a%=3+3;a%=6=>a=a%6=1;d=4+d*d+4;=>4+ 1.0+4=9.0d+= 1.5*3+(++a);=>d+= 4.5+2;d+= 6.5;=>d=7.5d-= 1.5*3+a++;=>d-= 4.5+1;=>d=1– 5.5=-4.55.22-4-416.(2+100)%7= 4.So it is Thursday.7.For byte,from-128to127,inclusive.For short,from-32768to32767,inclusive.For int,from-2147483648to2147483647,inclusive.For long,from-9223372036854775808to9223372036854775807.For float,the smallest positive float is1.40129846432481707e-45and the largest float is3.40282346638528860e+38.For double,the smallest positive double is4.94065645841246544e-324and the largest double is1.79769313486231570e+308d.8.25/4is 6.If you want the quotient to be a floating-point number,rewrite it as25.0/ 4.0,25.0/4,or25/ 4.0.9.Yes,the statements are correct.The printout is25/4is625/ 4.0is 6.253*2/4is13.0*2/4is 1.510. a. 4.0/(3.0*(r+34))–9*(a+b*c)+(3.0+d*(2+a))/(a+b*d)11. 1.0*m*(r*r)12.b and c are true.13.All.14.Line2:Missing static for the main method.Line2:string should be String.Line3:i is defined but not initialized before it isused in Line 5.Line4:k is an int,cannot assign a double value to k.Lines7-8:The string cannot be broken into two lines.15.long totalMills=System.currentTimeMillis()returns the milliseconds since Jan1,1970.long totalSeconds=totalMills/1000returns the total seconds.long totalMinutes=totalSeconds/60returns the total minutes.totalMinutes%60returns the current minute.16.Yes.Different types of numeric values can be used inthe same computation through numeric conversionsreferred to as casting.17.The fractional part is truncated.Casting does not change the variable being cast.18.f is12.5i is1219.System.out.println((int)'1');System.out.println((int)'A');System.out.println((int)'B');System.out.println((int)'a');System.out.println((int)'b');System.out.println((char)40);System.out.println((char)59);System.out.println((char)79);System.out.println((char)85);System.out.println((char)90);System.out.println((char)0X40);System.out.println((char)0X5A);System.out.println((char)0X71);System.out.println((char)0X72);System.out.println((char)0X7A);20.'\u345dE'is wrong.It must have exactly four hex numbers.21.'\\'and'\”'22.i becomes49,since the ASCII code of'1'is49;j become99since(int)'1'is49and(int)'2'is50;k becomes97since the ASCII code of'a'is97;c becomes character'z'since(int)'z'is90;23.char c='A';i=(int)c;//i becomes65float f=1000.34f;int i=(int)f;//i becomes1000double d=1000.34;int i=(int)d;//i becomes1000int i=97;char c=(char)i;//c becomes'a'24.bc-225.System.out.println("1"+1);=>11System.out.println('1'+1);=>50(since the Unicode for1is49System.out.println("1"+1+1);=>111System.out.println("1"+(1+1));=>12System.out.println('1'+1+1);=>5126.1+"Welcome"+1+1is1Welcome11.1+"Welcome"+(1+1)is1Welcome 2.1+"Welcome"+('\u0001'+1)is1Welcome21+"Welcome"+'a'+1is1Welcome a127.Class names:Capitalize the first letter in each name.Variables and method names:Lowercase the first word,capitalize the first letter in all subsequent words.Constants:Capitalize all letters.28.public class Test{/**Main method*/public static void main(String[]args){//Print a lineSystem.out.println("2%3="+2%3);}}pilation errors are detected by compilers.Runtimeerrors occur during execution of the program.Logicerrors results in incorrect results.30.The Math class is in the ng package.Any classin the ng package is automatically imported.Sothere is no need to import it explicitly.31.String s=JOptionPane.showInputDialog(“Enter aninput”);32.int i=Integer.parseInt(s);double s=Double.parseDouble(s);。

相关文档
最新文档