-3
if(code==1)
{
System.out.print("Enter product number: ");
int productnumber=Integer.parseInt(a.readLine());
System.out.print("Enter product name: ");
String productname=a.readLine();
System.out.print("Enter price: ");
int price1=Integer.parseInt(a.readLine());
System.out.println("");
{
int p=0;
for(int q=1;q<=1;q++)
{
System.out.println("1. Maintenance");
System.out.println("2. Transaction");
System.out.println("");
System.out.print("Enter Code: ");
int code1=Integer.parseInt(a.readLine());
System.out.println("");
}
}
{
int w;
for(productnumber=2; productnumber<=2; productnumber++)
{
System.out.println("Product number: "+productnumber);
System.out.print("Product name: ");
String prodname=a.readLine();
System.out.print("Price: ");
int price2=Integer.parseInt(a.readLine());
System.out.println("");
}
}
}
else if(code==2)
{
System.out.println("Display List of Product-Prices");
System.out.print("Display product number: ");
int productnumber2=Integer.parseInt(a.readLine());
System.out.println("Total: ");
System.out.print("Payment: ");
int payment=Integer.parseInt(a.readLine());
}
}
//这段代码有什么问题?有一个选项是1.维护和2.交易。如果我按数字1,它会读取这个以下代码:for循环里面的if和else如果
int w;
for(productnumber=2; productnumber<=2; productnumber++)
{
System.out.println("Product number: "+productnumber);
System.out.print("Product name: ");
String prodname=a.readLine();
System.out.print("Price: ");
int price2=Integer.parseInt(a.readLine());
System.out.println("");
//但是,如果我按数字2,它会读取与1号相同的代码..我该怎么办阅读当我按下数字2时,“else if(code == 2)”中的语句?感谢那些会帮助我的人。 :)
逻辑错误将在设置'code'的值的某个地方,以便向我们展示如果语句不会有多大帮助。 – leigero 2014-09-22 03:57:35
如何在变量'code'中获得值'1'或'2'? – Himanshu 2014-09-22 04:02:28
'for(int q = 1; q <= 1; q ++)'是什么意思? – 2014-09-22 04:03:18