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. //Prompt the user to enter their full name
  26. cout << "\nPlease enter your full name: ";
  27. cin.ignore();
  28. getline( cin, fullName );
  29.  
  30. //Display the name back to the user; and adds another line
  31. cout << "\nThank you " << fullName << endl;
  32.  
  33. //Display the age back to the user
  34. cout << "\nYou are " << age;
  35. cout << " years old; ";
  36.  
  37. //Display the amount of money back to the user
  38. cout << "\nand you have $" << money;
  39. cout << " in your pocket.";
  40.  
  41. //Giving the user an ending message
  42. cout << "\nGoodbye .....\n";
  43.  
  44. //Keeping the window open
  45. system("PAUSE");
  46.  
  47. //Return zero
  48. return 0;
  49. }
Success #stdin #stdout #stderr 0s 3432KB
stdin
25
10 
John Doe
stdout
Please enter your age: 
Please tell me how much money you have: 
Please enter your full name: 
Thank you 

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