
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
C#
I need to 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.)
Figure 8-5:(picture)
my errors are
Method DataEntry is defined to eliminate repetitive code
0 out of 1 checks passed. Review the results below for more details.
Unit Test Incomplete
Method DataEntry prompts the user to enter an integer and returns the integer
Build Status
Build Succeeded
Test Output
NUnit Console Runner 3.10.0 (.NET 2.0)
Copyright (c) 2019 Charlie Poole, Rob Prouse
Saturday, 04 February 2023 19:37:31
Runtime Environment
OS Version: Linux 5.0.0.27
CLR Version: 4.0.30319.42000
Test Files
NtTestf1b2147f.dll
Errors, Failures and Warnings
1) Failed : DataEntryMethodTest.DataEntryTest
Expected string length 19 but was 24. Strings differ at index 8.
Expected: "Enter third integer"
But was: "Enter the third integer:" -------------------^
at DataEntryMethodTest.DataEntryTest () [0x00000] in <6cf807bbba6c4dd284af123222270fc6>:0
Run Settings
DisposeRunners: True
WorkDirectory: /root/sandboxbf049929
ImageRuntimeVersion: 4.0.30319
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 4
Test Run Summary
Overall result: Failed
Test Count: 1, Passed: 0, Failed: 1, Warnings: 0, Inconclusive: 0, Skipped: 0
Failed Tests - Failures: 1, Errors: 0, Invalid: 0
Start time: 2023-02-04 19:37:32Z
End time: 2023-02-04 19:37:33Z
Duration: 1.157 seconds
[TestFixture]
public class DataEntryMethodTest
{
[Test]
public void DataEntryTest()
{
string consoleInput = "97";
int returnedValue;
string expectedString = "Enter third integer";
using (var inputs = new StringReader(consoleInput))
{
Console.SetIn(inputs);
using (StringWriter sw = new StringWriter())
{
Console.SetOut(sw);
returnedValue = InputMethodDemo2.DataEntry("third");
Assert.AreEqual(expectedString, sw.ToString().Trim());
Assert.AreEqual(97, returnedValue);
}
}
}
}
my code
using System;
using static System.Console;
class InputMethodDemo2
{
static void Main()
{
int first, second;
InputMethod(out first, out second);
WriteLine("After calling InputMethod, the first number is: {0}", first);
WriteLine("And the second number is: {0}", second);
}
private static void InputMethod(out int one, out int two)
{
one = DataEntry("first");
two = DataEntry("second");
}
public static int DataEntry(string prompt)
{
Write("Enter the {0} integer: ", prompt);
string input = ReadLine();
return Convert.ToInt32(input);
}
}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.Similar questions
- Write an application that inputs three integers from the user and displays the sum, average, product, smallest, and largest of the numbers. [Note: The calculation of the average should result in an integer representation of the average. So, if the sum of the values is 7, the average should be 2, not 2.3333….] For C# programmingarrow_forwardIn C/C++, True or False: A function that changes the value of a variable passed by reference also changes the value of the original variable. A variable's type helps define the amount of memory it takes to hold a value of that type.arrow_forwardT/F 2. In Java, only if and if-else expressions are used in selection statements.arrow_forward
- Please help me write it in C++arrow_forwardQuestion: In C#, how can I recreate this into a Windows form Application instead of a console application? Please show a photo of the display and show the code that you used, thank you! Problem: Write a function Seperate( number ) that separates an integer number (ranging from 0 to 99999) into its digits. For example, if the number is 42329, the function finds 4, 2, 3, 2, 9. If the number is 323, the function finds 0, 0, 3, 2, 3. (Hint: use modulus and integer division operations.) Code: using System;public class RecExercise4{static void Main(){Console.Write("Input any number (ranging from 0 to 99999) : ");int num = Convert.ToInt32(Console.ReadLine());Console.Write(" The digits in the number are : ");separateDigits(num);} static void separateDigits(int n){int i = 4;int[] arr;arr = new int[5];while (i>-1){arr[i] = n%10;n = n/10;i--;}foreach(int j in arr)Console.Write(" " + j);}}arrow_forwardPlease help in C++ languagearrow_forward
- Write VBA CODE FOR THE FOLLOWING PROBLEM Problem: The Worksheet named Grades contains a place for students to record the grades they have received in their classes. Students put the number of each letter grade received in the B column. (For example, the worksheet currently shows that the student has taken 9 classes and made five As, one B, one C, one D, and one F as grades. You need to write a program that reads the grades from the worksheet and uses a function to calculate the student’s GPA. For this problem you can assume that all classes are worth the same number of credit hours. The function should send back the GPA to the calling procedure. The procedure will then put up a message box that gives the student their GPA and a message about their GPA, all in one message box. The message should be “You qualify for an internship” if the student has a GPA of at least 3.0. It should be “You’re in the danger zone” if the GPA is between 2.0 and 3.0. And it should be “You are on…arrow_forwardWithin the tutorial casino craps game pseudocode, where should you place the pseudocode that performs the task of 'Get if the player won or lost', and how (in pseudocode) should this task be implemented? a.) In Function play, with pseudocode function play() ... set a local variable to won or lost b.) In Function play, with pseudocode function play() ... return if the player won or lost c.) In Loop until Games Played = Times to Play, with pseudocode Loop until Games Played = Times to Play ... If the player won ... Set "Get if the player won or lost" to won Else if player lost ... Set "Get if the player won or lost" to lost d.) In Loop until Games Played = Times to Play, with pseudocode Loop until Games Played = Times to Play ... If the player won ... Else if player lost ... Set "Get if the player won or lost" to won or lostarrow_forwardWrite a console in c#arrow_forward
- Drawa structured flowchart , C++, write pseudocode that describes the process of guessing a number between 1 and 100. After each guess, the player is told that the guess is too high or too low. The process continues until the player guesses the correct number. Pick a number and have a fellow student try to guess it following your instructions.arrow_forwardSubject: programming language : c++ Question : Jane has opened a new fitness center with charges of 2500 per month so the cost to become a member of a fitness center is as follow :1.For senior citizens discount is 30 %2. For young one the discount is 15 %3. For adult the discount is 20% Write a menu driven program (using structure c++) thata. Add a new memberb. Display the general information on about the fitness center and its chargesc. Determine the cost of a new membershipd. At any time show the total money made.Use appropriate parameters to pass information on and out of a function.arrow_forwardWritten in Carrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY