java 怎么设置循环_设置循环[关闭]

我正在尝试做一个程序,它接受三个首字母A,B,C之一的输入(简单地说三个系列首字母),然后提示输入一个数字(销售) . 程序需要继续要求另外一个用于三个初始,然后再用另一个数字 . 在用户输入Z结束时,程序结束但显示每个家庭的总销售额 .

关于如何设置这样的程序,我遇到了很多麻烦 .

向正确的方向推动会很棒 .

如果你想看到这个问题

是它的控制台基础 . 感觉不好显示代码但是

string QUIT = "Z";

string quit = "z";

string purchaseString;

string mainString;

double salesA = 0;

double salesB = 0;

double salesC = 0;

string andr1 = "a";

string andr2 = "A";

string bow1 = "b";

string bow2 = "B";

string clax1 = "c";

string clax2 = "C";

double purchase;

Console.WriteLine("To begin press anykey. To see total enter Z or Z ");

mainString = Console.ReadLine();

while ((mainString == andr1 || mainString == andr2) || mainString != QUIT && mainString != quit)

{

Console.WriteLine("Enter the persons Intials: ");

mainString = Console.ReadLine();

if (mainString == andr1 || mainString == andr2)

{

Console.Write("Enter next purchase amount: ");

purchaseString = Console.ReadLine();

purchase = Convert.ToDouble(purchaseString);

salesA += purchase;

}

if (mainString == bow1 || mainString == bow2)

{

Console.Write("Enter next purchase amount: ");

purchaseString = Console.ReadLine();

purchase = Convert.ToDouble(purchaseString);

salesB += purchase;

}

if (mainString == clax1 || mainString == clax2)

{

Console.Write("Enter next purchase amount: ");

purchaseString = Console.ReadLine();

purchase = Convert.ToDouble(purchaseString);

salesC += purchase;

}

}

Console.WriteLine("Total for Anderson, Bowman and Claxton respectively is {0} {1} {2}", salesA.ToString("c"), salesB.ToString("c"), salesC.ToString("c"));

Console.ReadLine();

}

}

}

有没有另一种方法来启动它没有

Console.WriteLine(“开始按任意键 . 要查看总计输入Z或Z”); mainString = Console.ReadLine(); while((mainString == andr1 || mainString == andr2)|| mainString!= QUIT && mainString!= quit)

似乎没必要

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值