another program

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 47
Reputation: joed13k1941 is an unknown quantity at this point 
Solved Threads: 0
joed13k1941 joed13k1941 is offline Offline
Light Poster

Re: another program

 
0
  #11
Oct 13th, 2008
these are the two screen shots he gave me as well
Attached Thumbnails
screen shot.jpg   screen shot 2.jpg  
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1463
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: another program

 
0
  #12
Oct 13th, 2008
Sorry, I'll have to get to this tomorrow evening if someone else has not answered your questions by then.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 47
Reputation: joed13k1941 is an unknown quantity at this point 
Solved Threads: 0
joed13k1941 joed13k1941 is offline Offline
Light Poster

Re: another program

 
0
  #13
Oct 13th, 2008
Thanks Ancient Dragon. I really appreciate the help. Hopefully I have it by then.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 32
Reputation: emotionalone is an unknown quantity at this point 
Solved Threads: 4
emotionalone emotionalone is offline Offline
Light Poster

Re: another program

 
0
  #14
Oct 13th, 2008
My first unit using iostream XD
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string softserve, topping, sprinkles;
  9. string order;
  10. do
  11. {
  12. cout << "Do you want chocolate, vanilla or twist?" << endl;
  13. getline(cin, softserve);
  14. }
  15. while( (softserve!="chocolate") && (softserve!="vanilla") && (softserve!="twist") );
  16. do
  17. {
  18. cout << "Hot fudge, chocolate or strawberry sauce?" << endl;
  19. getline(cin, topping);
  20. }
  21. while( (topping!="hot fudge") && (topping!="chocolate") && (topping!="strawberry") );
  22. do
  23. {
  24. cout << "Do you want sprinkles (yes/no)?" << endl;
  25. getline(cin, sprinkles);
  26. }
  27. while( (sprinkles!="yes") && (sprinkles!="no") );
  28. if (sprinkles == "yes")
  29. cout << "You ordered " << softserve << " ice cream with " << topping << " sauce and sprinkles." << endl;
  30. else
  31. cout << "You ordered " << softserve << " ice cream with " << topping << " sauce without sprinkles." << endl;
  32. cout << "Press a key to continue..." << endl;
  33. system("pause>nul");
  34. }
That should work fine.
Here you only accept answers in lowercase. and you do a do{}while(); for each input because you wanna reject each wrong answer for each input, not after all 3 inputs have been made, that would take more lines and achieve the same.
I just copied some of your codes and copy and pasted as I saw fit. My only real contribution, code wise, is the pause at the end, which I searched in cplusplus.com for
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,358
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1463
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: another program

 
0
  #15
Oct 13th, 2008
instead of system(pause>nul) why didn't you just simply use cin.get() ? you wouldn't have to have done all that net searching
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 47
Reputation: joed13k1941 is an unknown quantity at this point 
Solved Threads: 0
joed13k1941 joed13k1941 is offline Offline
Light Poster

Re: another program

 
0
  #16
Oct 13th, 2008
Originally Posted by emotionalone View Post
My first unit using iostream XD
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string softserve, topping, sprinkles;
  9. string order;
  10. do
  11. {
  12. cout << "Do you want chocolate, vanilla or twist?" << endl;
  13. getline(cin, softserve);
  14. }
  15. while( (softserve!="chocolate") && (softserve!="vanilla") && (softserve!="twist") );
  16. do
  17. {
  18. cout << "Hot fudge, chocolate or strawberry sauce?" << endl;
  19. getline(cin, topping);
  20. }
  21. while( (topping!="hot fudge") && (topping!="chocolate") && (topping!="strawberry") );
  22. do
  23. {
  24. cout << "Do you want sprinkles (yes/no)?" << endl;
  25. getline(cin, sprinkles);
  26. }
  27. while( (sprinkles!="yes") && (sprinkles!="no") );
  28. if (sprinkles == "yes")
  29. cout << "You ordered " << softserve << " ice cream with " << topping << " sauce and sprinkles." << endl;
  30. else
  31. cout << "You ordered " << softserve << " ice cream with " << topping << " sauce without sprinkles." << endl;
  32. cout << "Press a key to continue..." << endl;
  33. system("pause>nul");
  34. }
That should work fine.
Here you only accept answers in lowercase. and you do a do{}while(); for each input because you wanna reject each wrong answer for each input, not after all 3 inputs have been made, that would take more lines and achieve the same.
I just copied some of your codes and copy and pasted as I saw fit. My only real contribution, code wise, is the pause at the end, which I searched in cplusplus.com for
yes, this does work. but, it needs to ask all of the unanswered questions every time. so, if the user enters twist ice cream, it should ask for the sauce and sprinkles (not just the sauce). also, when it is started, it only asks for type of ice cream. it should ask all 3 questions to start
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 47
Reputation: joed13k1941 is an unknown quantity at this point 
Solved Threads: 0
joed13k1941 joed13k1941 is offline Offline
Light Poster

Re: another program

 
0
  #17
Oct 13th, 2008
All of the questions need to be inside of the loop I guess. That is what is giving me trouble. Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 47
Reputation: joed13k1941 is an unknown quantity at this point 
Solved Threads: 0
joed13k1941 joed13k1941 is offline Offline
Light Poster

Re: another program

 
0
  #18
Oct 13th, 2008
I spoke to my teacher and showed him the problem. He said it is a simple fix but of course he wouldn't tell me. I have been trying dozens of things (moving things around), but I cannot get it to work the way I want.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 47
Reputation: joed13k1941 is an unknown quantity at this point 
Solved Threads: 0
joed13k1941 joed13k1941 is offline Offline
Light Poster

Re: another program

 
0
  #19
Oct 14th, 2008
Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 32
Reputation: emotionalone is an unknown quantity at this point 
Solved Threads: 4
emotionalone emotionalone is offline Offline
Light Poster

Re: another program

 
0
  #20
Oct 14th, 2008
I'll work on the code once I get home, right now I got a class and I'm already late =s
But here's an idea:

The first question repeats once.
The second question repeats twice.
The third question repeats thrice

  1. int i, j, k;
  2. for( i=0; i<3 ; i++)
  3. {
  4. for( j=0; j < 2 && b; j++)
  5. {
  6. for( k=0; k <1 && c; k++)
  7. cout << "Do you want chocolate, vanilla or twist?\n";
  8. cout << "Hot fudge, chocolate or strawberry sauce?\n";
  9. }
  10. cout << "Do you want sprinkles (yes/no)?\n";
  11. if ( i == 0)
  12. cin >> softserver;
  13. if ( i == 1)
  14. cin >> topping;
  15. if ( i == 2)
  16. cin >> sprinkles;
  17. }

Well, I don't think that code may be going anywhere now that I've written some of it. But that's what I could come up in 15 minutes.
I'm 37 minutes late for class XD
Will get back with you...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC