如何在升级中一次使用JOptionPane.showMessageDialog

时间:2018-09-19 19:38:42

标签: java jgrasp

您使用过以下语句: JOptionPane.showMessageDialog吗?如果您的答案不止一次,请返回并 修改代码,以便仅使用一个JOptionPane.showMessageDialog

提示:考虑使用名为输出的字符串类型的变量

代码

如果(信用> = 120)

year = 18
number= 3
print( *[year]*number ,sep="\n")

2 个答案:

答案 0 :(得分:0)

使用if-else语句生成要显示的String,然后使用一行使用String调用showMessageDialog()

答案 1 :(得分:0)

//不要忘记导入JOptionPane库

//也不清楚您如何使用信用变量 公共课改 {     公共无效的showJoption(字符串位置)     {         JOptionPane.showMessageDialog(null,position);     }

public static void main(String[] args)
{
    //this is the class object that you can use to call the showJoption() method.
    prograde display = new prograde();

    if(credit >= 120)
    {
        display.showJoption("You've graduated!");
    }
    else if (credit >= 90)
    {
        display.showJoption("You're a senior.");
    }
    else if (credit >= 60)
    {
        display.showJoption("You're a junior.");
    }
    else if (credit >= 30)
    {
        display.showJoption("You're a sophomore.");
    }
    else if (credit >= 0)
    {
        display.showJoption("You're a freshment.");
    }
    else {
        display.showJoption("invalid input");
    }
}   

}