fork download
  1. #include <iostream> // compiler parses the code, character
  2. #include<string> // A token is one or more charaters
  3. using namespace std;
  4. int getTemp();
  5. string getMonth();
  6. void showInfo(int temp, string month);
  7.  
  8. int getAge();
  9. string getMessage();
  10. void showMessage(string msg);
  11. void showAge(int age);
  12. int main()
  13. {
  14. int temp;
  15. string month;
  16.  
  17. temp = getTemp();
  18. cin.ignore();
  19. month = getMonth();
  20. showInfo(temp, month);
  21.  
  22. string msg;
  23. msg = getMessage();
  24. showMessage(msg);
  25.  
  26. int age;
  27. age = getAge();
  28. showAge(age);
  29.  
  30.  
  31. return 0;
  32. }
  33. int getTemp(){
  34. int temp;
  35. cin>>temp;
  36. cout << "Enter the Temperature: "<< temp << endl;
  37. return temp;
  38. }
  39. string getMonth()
  40. {
  41. string month;
  42. getline(cin, month);
  43. cout << "Enter month: "<<month<<endl;
  44. return month;
  45.  
  46. }
  47. void showInfo(int temp, string month){
  48. cout<< "It is "<< temp << " degrees in "<< month <<endl;
  49. }
  50. int getAge()
  51. {
  52. int age;
  53. cin >> age;
  54. cout << "Enter your age: "<<age<<endl;
  55.  
  56. return age;
  57. }
  58. void showAge(int age)
  59. {
  60. cout << "The age is " << age << endl;
  61. }
  62. string getMessage(){
  63. string msg;
  64. getline(cin,msg);
  65. cout << "Enter your message: "<< msg << endl;
  66.  
  67. return msg;
  68. }
  69. void showMessage(string msg)
  70. {
  71. cout << msg<<endl;
  72. }
Success #stdin #stdout 0.01s 5312KB
stdin
78
December
Elvis never dies!
21
stdout
Enter the Temperature: 78
Enter month: December
It is 78 degrees in December
Enter your message: Elvis never dies!
Elvis never dies!
Enter your age: 21
The age is 21