首 页 行业热点 新车 试驾评测 养车用车 车型库
当前位置:首页(完整版)Java语言程序设计(基础篇)原书第十版梁勇著第一章答案

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

2024-08-11 来源:好土汽车网
导读 (完整版)Java语言程序设计(基础篇)原书第十版梁勇著第一章答案


第一章

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.11 public 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); }

}

因篇幅问题不能全部显示,请点此查看更多更全内容