首页上一页 1 下一页尾页 1 条记录 1/1页
public class Purchase {
public static void main(String[] args){
String info[][] = {{"舒适达牙膏","1","68.49"},{"益达口香糖","1","9.8"},{"大宝SOD蜜","1","9.9"}};
float sum = 0;
System.out.println("购物车明细如下:\n\n商品名称"+"\t\t"+"数量"+"\t"+"价格");
for(int i = 0;i<info.length;i++){
for(int j = 0;j<info[i].length;j++){
System.out.print(info[i][j]+"\t");
if(j==1){
int a = Integer.parseInt(info[i][j]);
float b = Float.parseFloat(info[i][j]+1);
sum += (float)a*b;
}
}
System.out.println();
}
System.out.println("您的付款总额为:"+sum+"元");
}
}
于2017-02-15 16:02:47编辑