fork(1) download
  1. // Nicolas Ruano CS1A Chapter 3 Pp.148 #22
  2. /*******************************************************************************
  3.  * WORD PROBLEM
  4.  * ____________________________________________________________________________
  5.  * This program is is performed to visualize the person's idenity
  6.  * ____________________________________________________________________________
  7.  * INPUT
  8.  * // NAME
  9.  * // AGE
  10.  * // NAME OF CITY LIVING IN
  11.  * // NAME OF COLLEGE
  12.  * // WHAT IS HIS/HER PROFFESION
  13.  * // WHAT KIND OF ANIMAL IS HIS/HER PET
  14.  * // NAME OF THE PET
  15.  * // COMCLUSION: THE BOTH LIVED HAPPILY EVER AFTER
  16.  * ____________________________________________________________________________
  17.  * OUTPUT
  18.  * // Display the person's story by name, age, place living in, the college he
  19.  * goes to, the profession he has, what kind of animal is his pet, and what is
  20.  * his pet's name.
  21. *******************************************************************************/
  22. #include <iostream>
  23. #include <string>
  24. using namespace std;
  25.  
  26. int main() {
  27. string name, city, college, profession, animal, petName;
  28. int age;
  29.  
  30.  
  31. cout << "Enter your name: Nicolas\n";
  32. getline(cin, name);
  33.  
  34. cout << "Enter your age: 20\n";
  35. cin >> age;
  36. cin.ignore();
  37.  
  38. cout << "Enter the name of a city: Dana Point\n";
  39. getline(cin, city);
  40.  
  41. cout << "Enter the name of a college: Saddleback\n";
  42. getline(cin, college);
  43.  
  44. cout << "Enter a profession: Concept Designer\n";
  45. getline(cin, profession);
  46.  
  47. cout << "Enter a type of animal: Dog\n";
  48. getline(cin, animal);
  49.  
  50. cout << "Enter a pet's name: Rocky\n";
  51. getline(cin, petName);
  52.  
  53. // Build the story
  54. cout << "\nHere is your story:\n\n";
  55. cout << "There once was a person named Nicolas" << name << " who lived in "<< city << "Dana Point.\n";
  56. cout << "At the age of " << age << "20, " << name << "went to college at " << college << "Saddleback.\n";
  57. cout << name << " graduated and went to work as a " << profession << "Concept Designer.\n";
  58. cout << "Then, " << name << "adopted a(n) dog" << animal << " named " << petName << "Rocky.\n";
  59. cout << "They both lived happily ever after!\n";
  60.  
  61. return 0;
  62. }
  63.  
  64.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Enter your name: Nicolas
Enter your age: 20
Enter the name of a city: Dana Point
Enter the name of a college: Saddleback
Enter a profession: Concept Designer
Enter a type of animal: Dog
Enter a pet's name: Rocky

Here is your story:

There once was a person named Nicolas who lived in Dana Point.
At the age of 178521741820, went to college at Saddleback.
 graduated and went to work as a Concept Designer.
Then, adopted a(n) dog named Rocky.
They both lived happily ever after!