fork download
  1. //declaring header mains
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. //Method: The main method
  7. //Purpose: To get the users name, age, and money; and return the information
  8. //Parameters: Name as string, age as integer, and money as a float value
  9. //Returns: Users inputted name, age, and money
  10. int main()
  11. {
  12. //Declaring variables
  13. string fullName;
  14. int age;
  15. float money;
  16.  
  17. //Promt the user to enter their age
  18. cout << "\nPlease enter your age: ";
  19. cin >> age;
  20.  
  21. //Prompt the user to enter their amount of money
  22. cout << "\nPlease tell me how much money you have: ";
  23. cin >> money;
  24.  
  25. cin.ignore(1, '\n'); // had to add this for it to work right for me
  26.  
  27. //Prompt the user to enter their full name
  28. cout << "\nPlease enter your full name: ";
  29. getline( cin, fullName);
  30.  
  31. //Display the name back to the user; and adds another line
  32. cout << "\nThank you " << fullName << endl;
  33.  
  34. //Display the age back to the user
  35. cout << "\nYou are " << age;
  36. cout << " years old; ";
  37.  
  38. //Display the amount of money back to the user
  39. cout << "\nand you have $" << money;
  40. cout << " in your pocket.";
  41.  
  42. //Giving the user an ending message
  43. cout << "\nGoodbye .....\n";
  44.  
  45. //Keeping the window open
  46. system("PAUSE");
  47.  
  48. // and finally, return zero
  49. return 0;
  50. }
Success #stdin #stdout #stderr 0s 3476KB
stdin
32
24.50
BHX Specter
stdout
Please enter your age: 
Please tell me how much money you have: 
Please enter your full name: 
Thank you BHX Specter

You are 32 years old; 
and you have $24.5 in your pocket.
Goodbye .....
stderr
sh: PAUSE: not found