当然,我不是光学JAVA的,还得学我自己专业的了。 学JAVA才一个星期吧! 先问一个/* **比较两个输入的数值大小 */import java.io.*;public class CompareTwo { public static void main(String[] args) throw IOException { int a; int b; String state;
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the first number :"); a=Integer.parseInt(stdin.readLine()); System.out.println("Enter the second number:"); b=Integer.parseInt(stdin.readLine());
编译了下 throws if语句写的不对 import java.io.*; public class CompareTwo { public static void main(String[] args) throws IOException { int a; int b; String state; BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the first number a:"); a=Integer.parseInt(stdin.readLine()); System.out.println("Enter the second number b:"); b=Integer.parseInt(stdin.readLine());
System.out.print("a= "+a); System.out.print(" "); System.out.println("b= "+b); if (a>b) { state="larger than"; System.out.println("a is "+state+" b"); } else if (a <b) { state="smaller than"; System.out.println("a is "+state+" b"); } else { state="equal to"; System.out.println("a is "+state+" b"); } } }
多敲敲代码
网上JAVA的视频很多~~
学JAVA才一个星期吧!
先问一个/*
**比较两个输入的数值大小
*/import java.io.*;public class CompareTwo {
public static void main(String[] args) throw IOException {
int a;
int b;
String state;
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the first number :");
a=Integer.parseInt(stdin.readLine());
System.out.println("Enter the second number:");
b=Integer.parseInt(stdin.readLine());
if (a>b) {
state="larger than";
System.out.println("a is"+state+"b");
}
else if (a<b) {
state="smaller than";
System.out.println("a is"+state+"b");
}
else {
state="equal to";
System.out.println("a is"+state+"b");
}
}
}
public static void main(String[] args) throw IOException {
import java.io.*; public class CompareTwo {
public static void main(String[] args) throws IOException {
int a;
int b;
String state; BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the first number a:");
a=Integer.parseInt(stdin.readLine());
System.out.println("Enter the second number b:");
b=Integer.parseInt(stdin.readLine());
System.out.print("a= "+a);
System.out.print(" ");
System.out.println("b= "+b); if (a>b) {
state="larger than";
System.out.println("a is "+state+" b");
} else if (a <b) {
state="smaller than";
System.out.println("a is "+state+" b");
} else {
state="equal to";
System.out.println("a is "+state+" b");
}
}
}
我也是新手。。