怎么调用while语句内的变量值 想调用while语句的值在外面使用
using System;namespace lainxi8
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("xxxxxxxxxxxxxxx");
Console.WriteLine ("1.T恤"+" "+"2.帽子");
Console.WriteLine ("xxxxxxxxxxxxxxx");
Console.WriteLine ("请开始你的购物 (y/n)");
string number=Console.ReadLine();
while(number="y")
{
Console.WriteLine ("请输入商品编号:");
int num = int.Parse (Console.ReadLine ());
Console.WriteLine ("请输入你的购物数量:");
int num1 = int.Parse (Console.ReadLine ());
if(num==1)
{
Console.WriteLine ("T恤"+" "+"$240"+" "+"数量:"+" "+num1+" "+"合计"+num1*240);
}
else
{
Console.WriteLine ("帽子"+" "+"$100"+" "+"数量"+" "+num1+" "+"合计"+num1*100);
}
Console.WriteLine ("是否继续购买(y/n)");
string nu=Console.ReadLine();
}
int a = (num1 * 240 + num1 * 100);
Console.WriteLine ("应付今额:"+a);
Console.WriteLine ("给钱:");
int b = int.Parse (Console.ReadLine ());
if(b>a)
{
Console.WriteLine ("找钱:"+(b-a)
);
}
else
{
Console.WriteLine ("你给的钱不够啊!!");
}
}
}
}
}
[此贴子已经被作者于2018-11-14 19:19编辑过]