// GetData() method accepts order number and quantity // that are used in the Ma
ID: 3658497 • Letter: #
Question
// GetData() method accepts order number and quantity // that are used in the Main() method // Price is #3.99 each using System; public class DebugSix1 { public static void Main() { int orderNum, quantity; double total; const double PRICE_EACH = 3.99; GetData(orderNum, quantity); total = quantity * PRICE_EACH; Console.WriteLine("Order #{0}. Quantity ordered = {1}", orderNum, quantity); Console.WriteLine("Total is {0}", total.ToString("C")); } public static void GetData(int order, out int amount) { String s1, s2; Console.Write("Enter order number: "); s2 = Console.ReadLine(); Console.Write("Enter quantity: "); s2 = Console.ReadLine(); order = Convert(s1); amount = Convert(s2); } }Explanation / Answer
/*Your's definition of GetData has a extra out. And it should be by reference*/ public static void GetData(ref int order, ref int amount) { String s1, s2; Console.Write("Enter order number: "); s1 = Console.ReadLine(); Console.Write("Enter quantity: "); s2 = Console.ReadLine(); order = Int32.Parse(s1); amount = Int32.Parse(s1); } Here I am providing you the link of running program compiling at my terminal http://pastie.org/5466454 Thanks :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.