我是C#的2周nube。我试图让用户输入一个数值(IE:你想要多少?),然后取这个值并计算税和总额。我无法弄清楚如何做到这一点,并想知道是否有人可以告诉我?谢谢,我现在的脚本是波纹管:处理用户输入(Mathmatical)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to Infinate Happiness Ranch.\nPlease enter your order information bellow. ");
Console.WriteLine();
Console.WriteLine("Please enter your first and last name:");
string FirstName = Console.ReadLine();
Console.WriteLine("Please enter your street address:");
string Address = Console.ReadLine();
Console.WriteLine("Please enter your city:");
string City = Console.ReadLine();
Console.WriteLine("Please enter your two letter state abreviation:");
string StateCode = Console.ReadLine();
Console.WriteLine("Please enter your zip code:");
string ZipCode = Console.ReadLine();
Console.WriteLine("Please enter the number of Tribbles \nyou wish to purchase for $29.99 plus tax");
string NumberOrdered = Console.ReadLine();
Console.WriteLine("Invoice \nName {0}", FirstName);
Console.WriteLine("Address {0}", Address);
Console.WriteLine("City {0}", City);
Console.WriteLine("StateCode {0}", StateCode);
Console.WriteLine("ZipCode {0}", ZipCode);
Console.WriteLine("NumberOrdered {0}", NumberOrdered);
// PROGRAM WORKS UNTIL HERE.
NumberOrdered = m;
TotalBeforeTax = m * 29.99; //'n' is total b4 tax
o = n * 0.9;// 'o' is total tax due
p = o + n; // 'p' is total due
Console.WriteLine("Your total is {0} {1}", n);
Console.WriteLine("Your tax is {0}", o);
Console.WriteLine("Your total charge is {0}", p);
Console.WriteLine("Thank you for your order");
Console.WriteLine();
//Console.WriteLine("Name:" + FirstName);
Console.Read();
}
}
}
你的程序不能编译。永远不要说你的程序“不起作用”。解释你期望发生什么,以及发生了什么。 –
什么是'm'?我没有看到它的定义。 –
这是一个相当长的程序。也许你可以删除所有不必要的东西,比如“使用”等? –