C++ problem

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

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

Npl_US · Feb 20, 2010 8:46 PM · 17,684 views

2 Replies

sajilo cha ta dude ke tension le rayako....i would have done it for you...but i don't know c++. I can provide you the hints... Ans 1)  1. read input and store runner Id and Name in key value pair using Dictionary or Hash 2. Do the input validation while reading the inputs 3. While printing find the first, second and third from dictionary/Hash and print it. Ans 2) 1. Use Switch Statement to perform the respective mathematical operation 2. Do input validation or use regular expression to valid the input from 1 to 5. If input is out from that boundary just print the exception message.  Last edited: 20-Feb-10 11:54 PM

wai_wai · Feb 20, 2010 11:54 PM

Dude, I can also help you on this, but I don't want to provide you line by line code.. as you have mentioned you try hard and unable to do it. Can you mentioned what was problem you faced and how much you succeed. Then based upon that I will try to give you a feedback.Also let me know how much of knowledge you have in C++. As "wai_wai" mentioned, you can use hash table and dictionary to work this program, but those will be little bit complicated. But as you are not experienced you can use simple array This is how you should implement (in the simplest form) Step 1: At first just write simple program which will accpe the number and name and try to see valdiation is working or not Step 2: declare 2 array of size 3 to store time and name. Try to figure out the which time is the smallest one, based upon that print the result IF you are interested then I can suggest the flow for second question in same way Last edited: 21-Feb-10 01:18 AM

khoi_k_khoi_k · Feb 21, 2010 12:49 AM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion

You might be interested in...

Recent Classifieds View all
Upcoming Events View all
Service Providers View all