fork download
  1. //Faith Tjia CSC5 Chapter 3, P. 148, #22
  2. //
  3. /*******************************************************************************
  4. * WORD GAME
  5. * ______________________________________________________________________________
  6. * This program will play a word game with the user, it will ask the user for
  7. * their name, their age, a city, a college, a profession, an animal, and a
  8. * pet's name, then will provide a story.
  9. * ______________________________________________________________________________
  10. * INPUT
  11. * name: name of user
  12. * age: age of user
  13. * cty: name of a city
  14. * clg: name of a college
  15. * prof: a profession
  16. * ani: a type of animal
  17. * pet: a pet's name
  18. *
  19. * OUTPUT
  20. * Story: There once was a person named NAME who lived in CITY.
  21. * At the age of AGE, NAME went to college at COLLEGE.
  22. * NAME graduated and went to work as a PROFESSION.
  23. * Then, NAME adopted a(n) ANIMAL named PETNAME.
  24. * They both lived happily ever after!
  25. *
  26. *******************************************************************************/
  27. #include <iostream>
  28. #include <iomanip>
  29. using namespace std;
  30.  
  31. int main()
  32. {
  33. string name; //INPUT - name of user
  34. string age; //INPUT - age of user
  35. string cty; //INPUT - name of a city
  36. string clg; //INPUT - name of a college
  37. string prof; //INPUT - a proffesion
  38. string ani; //INPUT - a type of animal
  39. string pet; //INPUT - a pet's name
  40. //
  41. // Initialize Program Variables
  42. cout << "Enter your name: ";
  43. cin >> name;
  44. cout << name << endl;
  45. cout << "Enter your age: ";
  46. cin >> age;
  47. cout << age << endl;
  48. cout << "Enter the name of a city: ";
  49. cin >> cty;
  50. cout << cty << endl;
  51. cout << "Enter the name of a college: ";
  52. cin >> clg;
  53. cout << clg << endl;
  54. cout << "Enter the name of a profession: ";
  55. cin >> prof;
  56. cout << prof << endl;
  57. cout << "Enter a type of animal: ";
  58. cin >> ani;
  59. cout << ani << endl;
  60. cout << "Enter a pet's name: ";
  61. cin >> pet;
  62. cout << pet << endl;
  63. //
  64. // Display The Story
  65. cout << "There once was a person named " << name << " who lived in " << cty
  66. << "." << endl;
  67. cout << "At the age of " << age << ", " << endl;
  68. cout << name << " went to college at " << clg << ". " << endl;
  69. cout << name << " graduated and went to work as a " << prof << ". " << endl;
  70. cout << "Then, " << name << endl;
  71. cout << "adopted a( n) " << ani << " named " << pet << "."
  72. << endl;
  73. cout << "They both lived happily ever after!" << endl;
  74. return 0;
  75. }
Success #stdin #stdout 0.01s 5272KB
stdin
Mercy
17
Sacramento
Harvard
doctor
cat
Melody
stdout
Enter your name: Mercy
Enter your age: 17
Enter the name of a city: Sacramento
Enter the name of a college: Harvard
Enter the name of a profession: doctor
Enter a type of animal: cat
Enter a pet's name: Melody
There once was a person named Mercy who lived in Sacramento.
At the age of 17, 
Mercy went to college at Harvard. 
Mercy graduated and went to work as a doctor. 
Then, Mercy
adopted a( n) cat named Melody.
They both lived happily ever after!