[Show all top banners]

Npl_US
Replies to this thread:

More by Npl_US
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 C++ problem
[VIEWED 6442 TIMES]
SAVE! for ease of future access.
Posted on 02-20-10 8:46 PM     Reply [Subscribe]
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

 
Posted on 02-20-10 11:54 PM     Reply [Subscribe]
Login in to Rate this Post:     1       ?         Liked by
 

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

 
Posted on 02-21-10 12:49 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?        
 

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

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 30 days
Recommended Popular Threads Controvertial Threads
TPS FEDERAL NOTICE
~चौतारी १९९~
TPS to change of status denied ..Need help
TPS to GC (PERM-I140-I485) TimeLine
TPS EAD rejected: Help
नफर्किने गरि नेपाल जाने सोच
हामीहरुले २० जना केटिहरुसंग सेक्स गर्नै पर्छ रे नी !
Mnang, Mustang Treking and Our Engagement
Salary offer aako cha
US upcoming recession --- is it good time to buy house when rates are low or is it good time to wait recession?
Is QA/BA worth considering a career ??
Turkish airline recent travel experience? Please share
थुक्क प्रियंका कार्कीजी …
Greencard ko bare
When does 90 day period start after 60 day grace period: OPT
चीन र जापानमा भन्दा पहिले नेपालमा बिजुली बलेकाे थियो | 2nd hydropower project of Asia
♪♪♪ हामी सबै क्लबमा ♪♪♪
लामिछानेको येस्पलीको दसैँ मामाघरमा
Thing to do for Parents after coming to USA.
अमेरिकामा एक नेपाली युवक आफ्नै ओछ्यानमा मृत भेटिए
~चौतारी १९९~
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters