Posted by: Npl_US February 20, 2010
C++ problem
Login in to Rate this Post:     0       ?        
Hello friends,
I terribly need help doing this c++ assignment, I try hard to do but I couldn't do it.. If anyone from sajha sathi do it for me will be highly appriciated.
Thank you advance... and my questions are as follows..

1)(Based on Gaddis textbook page 237 Programming Challenges question 14)

Write a program that asks the names of three runners and the time it took each of them to finish a race as integers.  The program should display who came in first, second and third place.

Input Validation:  Only accept positive numbers for the times.

Hint:  Suggest using cin.getline( name, 81) to get the names and to use cin.getline(time, 30) with atoi(time); to convert to an int.  Refer to example for help here:

Sample of the code/output

Enter the names of three runners and their finishing times.

I will tell you who came in first, second, and third.

Name of Runner 1: Terry

Runner 1's finishing time: 21

Name of Runner 2: Brad

Runner 2's finishing time: 18

Name of Runner 3: Michelle

Runner 3's finishing time: 19

Brad came in first place.

Michelle came in second place.

Terry came in third place.

2.
(Based on Gaddis textbook page 292  Programming Challenges question 8 math tutor)This program started in Programming Challenge 15 of Chapter 3 and was modified in the Programming Challenge 9 of Chapter 4. (Basically this is a math tutor for students that randomly asks math questions, waits for user evaluation and then gives the answer.

Do all the above and then modify the program again so it display a menu allowing the user to select an addition, subtraction, multiplication or division problem.  The final selection on the menu should let the user quit the program.  After the user has finished the Math problem, the program should display the menu again.  This process is repeated until the user chooses to quit the program.

Input Validation: If the user selects an item not on the menu , display an error message and display the menu again.             Example output proof:

            Menu

1. Addition problem

2. Subtraction problem

3. Multiplication problem

4. Division problem

5. Quit this program

Enter your choice (1-5): 4

 6 / 1 = 6

Congratulations! That's right.

        Menu

1. Addition problem

2. Subtraction problem

3. Multiplication problem

4. Division problem

5. Quit this program

Enter your choice (1-5): 8

The valid choices are 1, 2, 3, 4, and 5. Please choose: 5

Thank you for using Math Tutor.


 







Last edited: 20-Feb-10 08:51 PM
Read Full Discussion Thread for this article