所以我有这段代码,如果选项1的值不是0,我只希望执行选项2.如果它有0,则抛出错误。任何帮助表示赞赏。谢谢! :)
if (option == 1){
System.out.println("YOU HAVE SELECTED OPTION 1");
System.out.println(accounts[i].getOwner().getfirstName() + " " + accounts[i].getOwner().getlastName() + ", Please enter your yearly salary:");
accounts[i].setyearlySalary(in.nextDouble());
}
else if (option == 2){
System.out.println("YOU HAVE SELECTED OPTION 2");
System.out.println(accounts[i].getOwner().getfirstName() + " " + accounts[i].getOwner().getlastName() + ", Please enter any additional salary:");
accounts[i].setotherSalary(in.nextDouble());
}
答案 0 :(得分:0)
我建议您创建一个函数来设置额外的工资,并将其调用为选项2代码,如果选项1 == 0则调用。