1.写一个完整的Java应用程序,声明两个整型变量,分别赋值,在屏幕上输出他们的大小关系。

来源:百度知道 编辑:UC知道 时间:2024/05/15 20:18:15
麻烦帮忙写个JAVA程序谢谢!~
public class Example1_1 {
public static void main(String[] args) {
int a, b, sum;
a = Integer.parseInt(args[0]);
b = Integer.parseInt(args[1]);
sum = a + b;
System.out.println(a + "+" + b + "=" + sum);
}
}
就用这个帮我修改下就行了 麻烦你们

public class IntSort {
public static void main(String []args) {
int a = 10;
int b = 13;
System.out.println(a > b ? a : b);

}
}
不知道是不是你要的

import java.util.Scanner;
class Compare
{
private int a; /*整型变量成员a*/
private int b; /*整型变量成员b*/

public int scanInt(String type)
{
Scanner scan = null;
while (true)
{
try{/*异常捕捉*/
scan = new Scanner(System.in);
System.out.print("请输入"+type+"的值:");
return scan.nextInt();
}catch(Exception e){/*异常处理*/
System.out.println("你输入的数据错误!");
}
}
}

public void compareInt()/*比较后输出大小关系*/
{
if(a==b)
System.out.println(a+"="+b);
else
System.out.println(a>b?a+">"+b:a+"<"+b);
}

public static void main(String[] args)
{
Compare c =