Lab3

**CS 215 Summer 2012** **Lab 03** //**"C++ Loops"**//

The purpose of this lab assignment is to introduce conditional statements and loop. These allow programs to have varied functionality rather than a single execution flow. You will also do some basic error checking on user input.

Task 1 - Enter 'em

 * Prompt the user to enter the first names of two students
 * For each student, prompt the user to enter:
 * the sum of all lab scores and the problem set
 * the sum of all exam scores (mid term and final)
 * the sum of the programming assignments
 * the class participation grade
 * the sum of all quizzes
 * If, for any input, the user's number is not within a valid range, inform the user and end the program

Task 2 - The Moment of Truth

 * Calculate the total points and final letter grade of each student based on the entered values
 * Ask the user the order in which to display the final information: by name (alphabetical order) or by points (highest score first)
 * Display the name, number of points, and letter grade of each student, ordered as requested, Refer to the class syllabus to check how the letter grade is being calculated.


 * For task 1 and task 2:**
 * You may assume that the user will input text when prompted for text and integers when prompted for integers.
 * The statement "return 0;" may be used to end the program at any time.
 * As the programmer, it is up to you to determine how the user will indicate the desired display order.
 * The following table shows the acceptable ranges of inputs:
 * ~ Input ||~ Min ||~ Max ||
 * Labs & problem set || 0 || 30 ||
 * Exams || 0 || 30 ||
 * Programming assignments || 0 || 25 ||
 * Quizzes || 0 || 10 ||
 * Class Participation || 0 || 5 ||

Task 3 - Calculator
You need to design a calculator that performs four basic arithmetic operations. You will write a program that takes two numbers as input from the user. It then displays a list of arithmetic operations. The user selects one operation and the program displays the result of the corresponding operation. The program should also display which of the two input numbers is greater and which is smaller. Use do-while loop. Interaction with the program might look like the following:


 * Task 4 While loop**

Write a program that takes marks of 10 students as input. It calculates the class average and displays it on the screen. Interaction with the program might look like this. Use while loop.




 * Task 5**

Write a program that repeatedly asks the user to enter two money amounts expressed in pounds. The program should then add the two amounts and display the answer in pounds. The program should then convert the amount in Rupees. (Set conversion rate: 1£=120.33 rupees). Display the answer in Rupees. Use a do-while loop that asks the user whether the program should be terminated.




 * Task 6**

An aircraft system is designed which checks speeds and monitors various functions of the aircraft during the flight. Warnings and errors are generated if any fault develops during the flight. The system is coded in a manner that if 100 is entered as input it indicates “normal speed range”, if 101 is entered it gives “over-speed warning” indicating that aircraft is over-speeding. If 88 is entered, it indicates “Low Oil Pressure” and if 187 is entered it indicates “Engine Failure”. Use switch statement to implement this logic.

Note: In this case user enters the input for better understanding of the logic where as in real life situations input is generated through sensors and other electronic equipment on the aircrafts.