Assignment 3.docx - Assignment 3 \u2013 Loops Arrays 1 Multiple Choice Chapter 5 Pages 217 \u2013 219(odd 1 D 3 C 5 A 7 B 9 A 11 C 13 B 15 D 17 B 19 C 2

# Assignment 3.docx - Assignment 3 u2013 Loops Arrays 1...

This preview shows page 1 - 3 out of 3 pages.

Assignment 3 – Loops & Arrays 1. Multiple Choice Chapter 5: Pages 217 – 219 (odd) 1. D. 3. C. 5. A. 7. B. 9. A. 11. C. 13. B. 15. D. 17. B. 19. C. 2. Program problems: a. While Loop SumInts (Page 220 #2) static void Main(string[] args) { int Num=0; int Sum=0; while (Num != 999) { Console.WriteLine("Please enter a number:"); Num = Convert.ToInt32(Console.ReadLine()); if (Num != 999) { Sum = Sum + Num; } } Console.WriteLine("The sum of all the numbers is {0}", Sum); Console.ReadLine(); } b. While Loop HomeSales (Page 220 #5) string initial = "" ; double Danielle = 0.00; double Edward = 0.00; double Francis = 0.00; double total = 0.00; Console.WriteLine( "Welcome. The Holiday Homes sales people are: Danielle, Edward, & Francis." ); Console.ReadLine(); while (initial != "z" && initial != "Z" ) { Console.WriteLine( "Enter a salesperson's first initial: " ); initial = Console.ReadLine();
if (initial == "D" || initial == "E" || initial == "F" ) { Console.WriteLine( "Enter sales amount: " ); double salesAmount = Convert.ToDouble(Console.ReadLine()); if (initial == "D" ) Danielle += salesAmount; else if (initial == "E" ) Edward += salesAmount; else if (initial == "F" ) Francis += salesAmount; total = Danielle + Edward + Francis; } else Console.WriteLine(

#### You've reached the end of your free preview.

Want to read all 3 pages?

• Spring '10
• NEWBY
• 2005 albums