Advertisement
Felanpro

Remembering (Console Application)

Oct 24th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. /*Tutorial from youtuber (Section 1)
  7.  
  8. float age = 18; //whole number
  9. //float temp = 97, 4; //decimal number
  10. char gender = 'm'; //single letter
  11. //bool found = false; //true or false
  12. //const float PI = 3.14; //more precise decimal
  13.  
  14. /*
  15. age = age + 1; //all this 3 methods are used to add 1 to the number. In this case 18 + 1. It is just different methods.
  16. age += 1;
  17. age++;
  18. */
  19.  
  20. /*
  21. age = 9 * 5;
  22. cout << age << endl;
  23. age = 9.0 / 4; // you can change int age to float age and then do age = 9.0 / 4 and it will display 2.25
  24. cout << age << endl;
  25. */
  26.  
  27. /*
  28. cout << "Enter your age and then enter your gender(m or f): ";
  29. cin >> age >> gender;
  30. cout << "You are: "<< age << "years old. You are a " << gender << endl;
  31. */
  32. /*
  33. int x = 9;
  34.  
  35. age = x / 4;
  36. cout << age << endl;
  37. age = static_cast<float>(x) / 4;
  38. cout << age << endl;
  39. */
  40.  
  41.  
  42. //Tutorial followed by youtuber (Section 2)
  43.  
  44. /*basic if statement
  45.  
  46. int a = 10;
  47. int z = -10;
  48.  
  49. if (a > 0 && z > 0) // && = and , || = or
  50. cout << "A & Z are positive." << endl;
  51. else if (a == 0 && z == 0)
  52. cout << "A & Z are zero" << endl;
  53. else if (a < 0)
  54. cout << "A is negative." << endl;
  55. else if (a > 0 || z > 0)
  56. cout << "One of the numbers is positive." << endl;
  57. else if (a < 0 || z < 0)
  58. cout << "One of the numers is negative." << endl;
  59. */
  60.  
  61. //Switch, often used for menus.
  62.  
  63. int choice;
  64. cout << "1.Small dog" << endl;
  65. cout << "2.Large dog" << endl;
  66. cout << "3.Squid" << endl;
  67. cout << "Please enter the menu number that corresponds to your animal: ";
  68. cin >> choice;
  69. switch (choice)
  70. {
  71. case 1:
  72. cout << "Cost: $50.00" << endl;
  73. break;
  74. case 2:
  75. cout << "Cost: $25.00" << endl;
  76. break;
  77. case 3:
  78. cout << "Cost: 1.50" << endl;
  79. break;
  80. default:
  81. cout << "Invalid option!" << endl;
  82. break;
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement