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.  
  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. // and finally, return zero
  46. return 0;
  47. }
Success #stdin #stdout 0s 3432KB
stdin
12
24.00
BHX Specter
stdout
Please enter your age: 
Please tell me how much money you have: 
Please enter your full name: 
Thank you 

You are 12 years old; 
and you have $24 in your pocket.
Goodbye .....