【发布时间】:2017-06-27 18:37:44
【问题描述】:
我制作了一个具有以下 sn-p 的 switch-case Restaurant 程序:
for(int r=0;r<=17;r++)
{
while(qty[r]>0)
{
System.out.println(qty[r]+" X "+O[r]+" "+l[r]);
break;
}
}
//qty has the quantity(int) ; O has the Item name (String) and l has the cost (int)
由于字符串长度不同,输出不统一——没有正确对齐。
输出:
*********************************************************
*********************************************************
**************************BILL***************************
Thu Feb 09 22:01:36 IST 2017
Your phone number - 9821809843
Bill number is 4180536
You have ordered :
Item Name with quantity Price
1 X Fried Raviolli 400
1 X Potato Fries with Jalapeno and Cheese Dip 800
The total bill amount is Rs.1200
Hope you enjoyed. Visit us again soon!
关于如何纠正此问题的任何想法?
【问题讨论】:
-
@nhouser9 是的,这在一定程度上解决了我的问题。但由于我是新手,我不确定如何编辑我的 sn-p。请帮我一个忙,告诉我怎么做。提前致谢!
-
好的,我在下面发布了答案。如果有帮助,请记得点赞并接受。
标签: java arrays printing alignment