View Single Post
Old May 4th, 2008, 2:20 PM   #10
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 92
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Re: Simple if statement question :(

Here's your code indented and fixed up a bit.

c++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main(void)
  6. {
  7. system("TITLE Addition");
  8. system("COLOR 3");
  9. int number1 = 0, number2 = 0, number3 = 0, number4 = 0, sum = 0;
  10. // int one = 1; <-- never used
  11. string yesno;
  12. // string relay; <-- useless
  13. bool bCont = true;
  14. while (bCont) {
  15. cout<<"I'm going to add these numbers you give me. First Number: ";
  16. cin>>number1;
  17. cout<<"next number: ";
  18. cin>>number2;
  19. cout<<"and the next number: ";
  20. cin>>number3;
  21. cout<<"and the last number: ";
  22. cin>>number4;
  23. sum = number1 + number2 + number3 + number4;
  24.  
  25. if(sum < 10)
  26. cout<<"Your number is " << sum << " and it is a small number. \n";
  27. else if ( sum > 10 && sum < 50 )
  28. cout<<"Your number is " << sum << " and it is a big number. \n";
  29. else if (sum > 50 && sum <150 )
  30. cout<<"Your number is " << sum << " and it is a large number. \n";
  31. else
  32. cout<<"You have a really big number \n" ;
  33.  
  34. cout<<"Try again? Y/N: ";
  35. cin>> yesno;
  36. if (yesno == "Y" || yesno == "y")
  37. continue;
  38. else
  39. bCont = false;
  40. }
  41. cin.get();
  42. return 0;
  43. }
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote