Question: please please help due at 1159 tonight! here is the question C# cengage mindtap Write a program named InputMethodDemo2 that eliminates the repetitive code in
please please help due at 1159 tonight!
here is the question C# cengage mindtap
Write a program named InputMethodDemo2 that eliminates the repetitive code in the InputMethod() in the InputMethodDemo program in Figure 8-5.
Rewrite the program so the InputMethod() contains only two statements:
one = DataEntry("first"); two = DataEntry("second"); (Note: The program in Figure 8-5 is provided as starter code.)

here's my code it says its wrong
using System;
class Program { private static void InputMethod(out int one,out int two) { one=DataEntry("first"); two=DataEntry("second"); } public static int DataEntry(string whichOne) { int temp=Convert.ToInt32(Console.ReadLine()); return temp; } static void Main() { int first,second; Program.InputMethod(out first,out second); Console.WriteLine("After InputMethod first is {0}",first); Console.WriteLine("and second is {0}",second); } }
here's the error it gave me
InputMethodDemo2.cs(17,1): error CS0103: The name `Program' does not exist in the current context NtTest6cb3c066.cs(21,30): error CS0103: The name `InputMethodDemo2' does not exist in the current context
using System; using static System.Console; class Input MethodDemo Notice the { keyword out. static void Main() { int first, second; Input Method (out first, out second); WriteLine("After InputMethod first is {0}", first); WriteLine("and second is {0}", second); } private static void InputMethod(out int one, out int two) { string si, s2; Write("Enter first integer "); sl = ReadLine(); Notice the Write("Enter second integer "); keyword out. s2 = ReadLine(); one = Convert.ToInt32 (s1); two = Convert.ToInt32(s2); } } Figure 8-5 The InputMethodDemo program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
