Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What I need: In C#, Write a program named InputMethodDemo2 that eliminates the repetitive code in the InputMethod() in the InputMethodDemo program in Figure 8-5.

What I need:

In C#,

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");

What I have:

using System; class InputMethodDemo2 { static void Main() { int first, second; InputMethod(out first, out second); Console.WriteLine("After InputMethod first is {0}", first); Console.WriteLine("and second is {0}", second); } private static void InputMethod(out int one, out int two) { one = DataEntry("first"); two = DataEntry("second");

} public static int DataEntry(string myString) { string inputString; Console.Write("Enter first integer ", myString); inputString = Console.ReadLine(); return Convert.ToInt32(inputString); }

}

Error I get:

Errors, Failures and Warnings 1) Failed : DataEntryMethodTest.DataEntryTest String lengths are both 19. Strings differ at index 6. Expected: "Enter third integer" But was: "Enter first integer" -----------------^ at DataEntryMethodTest.DataEntryTest () [0x00000] in <20bcea967c33483d8c05931ba220cd13>:0 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions