(完整版)Java语言程序设计(基础篇)原书第十版梁勇著第一章答案

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

第一章
1.1 public class Test{
public static void main(String[] args){
System.out.println("Welcome to Java !");
System.out.println("Welcome to Computer Science !");
System.out.println("Programming is fun .");
}
}
1.2 public class Test{
public static void main(String[] args){
for(int i = 0;i <= 4;i++){
System.out.println("Welcome to Java !");
}
}
}
1.3 public class Test{
public static void main(String[] args){
System.out.println(" ]");
System.out.println(" ]");
System.out.println("] ]");
System.out.println(" ]]");
}
}
public class Test{
public static void main(String[] args){
System.out.println(" A");
System.out.println(" A A");
System.out.println(" AAAAA");
System.out.println("A A");
}
}
public class Test{
public static void main(String[] args){
System.out.println("V V");
System.out.println(" V V");
System.out.println(" V V");
System.out.println(" V");
}
}
1.4 public class Test{
public static void main(String[] args){
System.out.println("a a^2 a^3");
System.out.println("1 1 1");
System.out.println("2 4 8");
System.out.println("3 9 27");
System.out.println("4 16 64");
}
}
1.5 public class Test{
public static void main(String[] args){
System.out.println((9.5*4.5-2.5*3)/(45.5-3.5));
}
}
1.6 public class Test{
public static void main(String[] args){
int i = 1,sum = 0;
for(;i <= 9;i++)
sum += i;
System.out.println(sum);
}
}
1.7 public class Test{
public static void main(String[] args){
System.out.println(4*(1.0-1.0/3+1.0/5-1.0/7+1.0/9-1.0/11));
System.out.println(4*(1.0-1.0/3+1.0/5-1.0/7+1.0/9-1.0/11+1.0/13)) ;
}
}
1.8 public class Test{
public static void main(String[] args){
final double PI = 3.14;
double radius = 5.5;
System.out.println(2 * radius * PI);
System.out.println(PI * radius * radius);
}
}
1.9 public class Test{
public static void main(String[] args){
System.out.println(7.9 * 4.5);
System.out.println(2 * (7.9 + 4.5));
}
}
1.10 public class Test{
public static void main(String[] args){
double S = 14 / 1.6;
double T = 45 * 60 + 30;
double speed = S / T;
System.out.println(speed);
}
}
1.11public class Test{
public static void main(String[] args){
int BN = 312032486; //original person numbers
double EveryYS,EveryYBP,EveryYDP,EveryYMP;
EveryYS = 365 * 24 * 60 * 60;
EveryYBP = EveryYS / 7;
EveryYDP = EveryYS / 13;
EveryYMP = EveryYS / 45;
int FirstYP,SecondYP,ThirdYP,FourthYP,FivthYP;
FirstYP = (int)(BN + EveryYBP + EveryYMP - EveryYDP);
SecondYP = (int)(FirstYP + EveryYBP + EveryYMP - EveryYDP);
ThirdYP = (int)(SecondYP + EveryYBP + EveryYMP - EveryYDP);
FourthYP = (int)(ThirdYP + EveryYBP + EveryYMP - EveryYDP);
FivthYP = (int)(FourthYP + EveryYBP + EveryYMP - EveryYDP);
System.out.println(FirstYP);
System.out.println(SecondYP);
System.out.println(ThirdYP);
System.out.println(FourthYP);
System.out.println(FivthYP);
}
}
1.12 public class Test{
public static void main(String[] args){
double S = 24 * 1.6;
double T = (1 * 60 + 40) * 60 + 35;
double speed = S / T;
System.out.println(speed);
}
}
1.13 import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("input a,b,c,d,e,f value please:");
double a = input.nextDouble();
double b = input.nextDouble();
double c = input.nextDouble();
double d = input.nextDouble();
double e = input.nextDouble();
double f = input.nextDouble();
double x,y;
x = (e * d - b * f) / (a * d - b * c);
y = (a * f - e * c) / (a * d - b * c);
System.out.println("The result is x: "+(int)(x * 1000) / 1000.0);
System.out.println("The result is y: "+(int)(y * 1000) / 1000.0);
}
}。

相关文档
最新文档