Question
Develop a C# console application that implements two parallel int arrays in Main, one called apartment and the other called rent. Each array will hold
Develop a C# console application that implements two parallel int arrays in Main, one called apartment and the other called rent. Each array will hold 5 integer values. Use an initializer to fill the apartment array with the values {123, 204, 601, 609, 612}. Use an initializer to fill the rent array with the values {500, 750, 495, 800, 940}.
Create two static methods, one called getRent and one called printit. When the getRent method is called from Main you should pass the apartment array by reference, the rent array by reference and the apartment number console entry.
In the getRent method you should use a for loop to match apartment number passed to the method and match it to the apartment numbers in the apartment array that was passed to the getRent. When a match is found in the apartment number array call the printit method from the getRent method and pass by value the apartment number and the matching rent value from the rent array to the printit method.
In the printit method print the apartment number and the rent for that apartment to the console as shown in the output example below. When you print the output, instead of using a string concatenation (Console.WriteLine("Rent for apartment # " + choice + " is $" + rent);) use a StringBuilder object. The string parts of the message ("Rent for apartment #" and " is $") should be declared as separate strings. Using the StringBuilder object methods, you will append the two strings and two integer values together and write the final appended output to the console. The appends and output should all be done in the print method.
Enter the apartment number 601 Rent for apartment # 601 is $495 Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started