怎么用JAVA语言做这题

来源:百度知道 编辑:UC知道 时间:2024/05/26 18:51:13
switch(grade)
{
case 7:
case 6: a=11;
b=22;
break;
case 5: a=33;
b=44;
break;
default: a=55;
break;
}

/*先从键盘上接收grade的值,然后调用 switch,最后输出a, b
*/

import java.util.Scanner;
public class question
{
public static void main(String[] args)
{
System.out.println("enter the value of grade:");

//接收输入值
Scanner sc = new Scanner(System.in);
grade = sc.nextInt();

switch(grade)
{
case 7:
case 6:
a=11;
b=22;
break;
case 5:
a=33;
b=44;
break;
default: a=55;
break;
}

System.out.println("a=" + a + "\n" + "b=" + b);
}
static int grade;
static int a;
static int b;
}

import javax.swing.*;
public class question
{
public static void main(String[] args)
{

int a , b, grade;
String s;
s=JOptionPane.showInputDialog("输入一个数:");
grade=Integer.parseInt(s);

sw