1 import java.util.*;
2 public class Prints {
3
4 int x;
5
6
7 void getoutput()
8 {
9 if(x==1)
10 {
11 System.out.println("ABCD");
12 }
13 else if(x==2)
14 {
15 System.out.println("abcd");
16 }
17 }
18
19
20
21 public static void main(String[] args)
22 {
23
24 Scanner s=new Scanner(System.in);
25 Prints b=new Prints();
26 System.out.println("请输入1和2");
27 b.x=s.nextInt();
28 b.getoutput();
29 }
30 }
31 /*
32 题目 编写Java应用程序。首先,定义一个Print类,它有一个方法void output(int
33 x),如果x的值是1,在控制台打印出大写的英文字母表;如果x的值是2,在
34 控制台打印出小写的英文字母表。其次,再定义一个主类——TestClass,在主类
35 的main方法中创建Print类的对象,使用这个对象调用方法output ()来打印出大
36 小写英文字母表。
1 import java.util.*;
2 public class Prints {
3
4 int x;
5
6
7 void getoutput()
8 {
9 if(x==1)
10 {
11 System.out.println("ABCD");
12 }
13 else if(x==2)
14 {
15 System.out.println("abcd");
16 }
17 }
18
19
20
21 public static void main(String[] args)
22 {
23
24 Scanner s=new Scanner(System.in);
25 Prints b=new Prints();
26 System.out.println("请输入1和2");
27 b.x=s.nextInt();
28 b.getoutput();
29 }
30 }
31 /*
32 题目 编写Java应用程序。首先,定义一个Print类,它有一个方法void output(int
33 x),如果x的值是1,在控制台打印出大写的英文字母表;如果x的值是2,在
34 控制台打印出小写的英文字母表。其次,再定义一个主类——TestClass,在主类
35 的main方法中创建Print类的对象,使用这个对象调用方法output ()来打印出大
36 小写英文字母表。
1 import java.util.*;
2 public class Prints {
3
4 int x;
5
6
7 void getoutput()
8 {
9 if(x==1)
10 {
11 System.out.println("ABCD");
12 }
13 else if(x==2)
14 {
15 System.out.println("abcd");
16 }
17 }
18
19
20
21 public static void main(String[] args)
22 {
23
24 Scanner s=new Scanner(System.in);
25 Prints b=new Prints();
26 System.out.println("请输入1或2");
27 b.x=s.nextInt();
28 b.getoutput();
29 }
30 }
31 /*
32 题目 编写Java应用程序。首先,定义一个Print类,它有一个方法void output(int
33 x),如果x的值是1,在控制台打印出大写的英文字母表;如果x的值是2,在
34 控制台打印出小写的英文字母表。其次,再定义一个主类——TestClass,在主类
35 的main方法中创建Print类的对象,使用这个对象调用方法output ()来打印出大
36 小写英文字母表。