1.1
public class Exercise1_1 {
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 Exercise1_2 {
public static void main(String[] args){
for(int i = 0; i < 5; i++)
System.out.println("第"+(i+1)+"个"+"Welcome to Java!");
}
}
1.3
public class Exercise1_3 {
public static void main(String[] args){
System.out.println(" J A V V A ");
System.out.println(" J A A V V A A ");
System.out.println("J J AAAAA V V AAAAA ");
System.out.println(" J J A A V A A ");
}
}
1.4
public class Exercise1_4 {
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 Exercise1_5 {
public static void main(String[] arga){
System.out.println((9.5 * 4.5 - 2.5 * 3) / (45.5 - 3.5));
}
}
Output:0.8392857142857143
1.6
public class Exercise1_6 {
public static void main(String[] arga){
System.out.println(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9);
}
}
Output:45
1.7
public class Exercise1_7 {
public static void main(String[] args){
System.out.println(4 * (1 - 1.0 / 3 + 1.0 / 5 - 1.0 /7 + 1.0 / 9 - 1.0 / 11 + 1.0 /13));
}
}
Output:3.2837384837384844