SUNIL GUTTA

SUNIL GUTTA

  • NA
  • 1k
  • 394k

c# console app assistance

Nov 6 2013 12:54 AM
Hi

In developing this code, I keep hitting setbacks and can't get past some of this. Any assistance would be greatly appreciated.



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 . . .


Cheers & have a nice day 


Answers (4)