Advertisement
InasAwad

Untitled

Mar 14th, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void LargestNumber(int x, int y, int z) {
  5.  
  6. if ((x > y) && (x > z)) {
  7. cout << "Largest is: " << x << endl;
  8. }
  9. else if ((y > x) && (y > z)) {
  10. cout << "Largest is: " << y << endl;
  11.  
  12. }
  13. else {
  14. cout << "Largest is: " << z << endl;
  15. }
  16. }
  17.  
  18. void SmallestNumber(int x, int y, int z) {
  19. if ((x < y) && (x < z)) {
  20. cout << "Smallest is: " << x << endl;
  21. }
  22. else if ((y < x) && (y < z)) {
  23. cout << "Smallest is: " << y << endl;
  24.  
  25. }
  26. else {
  27. cout << "Smallest is: " << z << endl;
  28. }
  29. }
  30.  
  31. void IsLargerOrEqual() {
  32. int x, y;
  33. cout << "Please enter the value of x: ";
  34. cin >> x;
  35.  
  36. cout << "Please enter the value of y: ";
  37. cin >> y;
  38. if (y == x) {
  39. cout << "x is equal to y.";
  40. }
  41. else if (x > y) {
  42. cout << "x is larger than y.";
  43. }
  44. else
  45. {
  46. cout << "y is larger thatn x.";
  47. }
  48. }
  49. void SquareCube() {
  50. cout << "Interger " << "Square " << " Cube " << endl;
  51. for (int i = 1; i < 11; i++) {
  52. cout << i << " " << i * i << " " << i * i * i << endl;
  53.  
  54. }
  55. }
  56.  
  57. void CalculateBMI(double weight, double height) {
  58. double bmi = (weight * 703) / (height * height);
  59. cout << "BMI VALUES\n" << "Underweight: less than 18.5\n" << "Normal : between 18.5 and 24.9 \n"
  60. << "Overweight : between 25 and 29.9\n" << "Obese : 30 or greater\n" << "Your BMI is: " << bmi << endl;
  61.  
  62. }
  63.  
  64. void CalculateGasCost() {
  65. double gallonsPerDay, gallonCost, parkingCost, tollsCost;
  66. cout << "Please enter below values : \n" << "Number of gallons per day: \n";
  67. cin >> gallonsPerDay;
  68. cout << "The cost per gallons: \n";
  69. cin >> gallonCost;
  70. cout << "Parking cost: \n";
  71. cin >> parkingCost;
  72. cout << "Please enter the tolls cost \n";
  73. cin >> tollsCost;
  74. double totalCostPerDay = 0;
  75. totalCostPerDay = (gallonsPerDay * gallonCost) + parkingCost + tollsCost;
  76. cout << "Your total cost per day is : " << totalCostPerDay << endl;
  77. }
  78.  
  79. void DrawingASquare() {
  80.  
  81. cout << "* * * * * * * * * " << endl;
  82. int spaces = 2;
  83. int stars = 1;
  84. for (int i = 0; i < 5; i++) {
  85. for (int j = 0; j < stars; j++) {
  86. cout << "*";
  87. }
  88. for (int j = 0; j < spaces; j++) {
  89. cout << " ";
  90. }
  91. for (int j = 0; j < stars; j++) {
  92. cout << "*";
  93. }
  94. cout << endl;
  95. }
  96. cout << "* * * * * * * * * " << endl;
  97.  
  98. }
  99. void DrawingTShape() {
  100. int spaces = 3;
  101. int stars = 1;
  102. for (int i = 0; i < 3; i++) {
  103. for (int j = 0; j < spaces; j++) {
  104. cout << " ";
  105. }
  106. spaces--;
  107. for (int j = 0; j < stars; j++) {
  108. cout << "*";
  109. }
  110. cout << endl;
  111. stars += 2;
  112. }
  113. int spaces1 = 3;
  114. int star = 1;
  115. for (int i = 0; i < 7; i++) {
  116. for (int j = 0; j < spaces1; j++) {
  117. cout << " ";
  118. }
  119. for (int j = 0; j < star; j++) {
  120. cout << "*";
  121. }
  122. cout << endl;
  123. }
  124. }
  125. void DrawingADiamond() {
  126. int spaces1 = 7;
  127. int star = 1;
  128. int spaces2 = 0;
  129. for (int i = 0; i < 6; i++) {
  130. for (int j = 0; j < spaces1; j++) {
  131. cout << " ";
  132. }
  133. cout << "*";
  134. spaces1--;
  135. for (int j = 0; j < spaces2; j++) {
  136. cout << " ";
  137. }
  138. cout << "*";
  139. spaces2 += 2;
  140. cout << endl;
  141. }
  142. for (int i = 0; i < 6; i++) {
  143. for (int j = 0; j < spaces1; j++) {
  144. cout << " ";
  145. }
  146. spaces1++;
  147. cout << "*";
  148. for (int j = 0; j < spaces2; j++) {
  149. cout << " ";
  150. }
  151. cout << "*";
  152. spaces2 -= 2;
  153. cout << endl;
  154. }
  155. cout << " *" << endl;
  156. }
  157.  
  158.  
  159. int main(){
  160. //int x, y, z;
  161. //cout << "Please enter three numbers: " << endl;
  162. //cin >> x >> y >> z;
  163. ////IsLargerOrEqual();
  164. //LargestNumber(x,y,z);
  165. //SmallestNumber(x,y,z);
  166. //cout << "The sum : " << x + y + z << endl;
  167. //cout << "The product : " << x * y * z << endl;
  168. //cout << "The average : " << (x + y + z) / 3 << endl;
  169.  
  170. /* double radius;
  171. const double x = 3.14159;
  172. cout << "Please enter the radius : " << endl;
  173. cin >> radius;
  174. cout << "The diameter : " << radius * 2 << endl;
  175. cout << "The circumference : " << (radius * 2) * x << endl;
  176. cout << "The area " << (radius * radius) * x << endl;*/
  177.  
  178. /* int numstars{};
  179. std::cin >> numstars;
  180. for (int i = 0; i < numstars; ++i)
  181. cout << string(numstars, '*') << '\n';*/
  182.  
  183. /*int number, n1, n2, n3, n4, n5;
  184. cout << "Please enter a 5 digis number: " << endl;
  185. cin >> number;
  186. n1 = number % 10;
  187. number = number / 10;
  188. n2 = number % 10;
  189. number = number / 10;
  190. n3 = number % 10;
  191. number = number / 10;
  192. n4 = number % 10;
  193. number = number / 10;
  194. n5 = number % 10;
  195. cout << n5 << " " << n4 << " " << n3 << " " << n2 << " " << n1 << " " << endl;
  196.  
  197. cout << "**~~**~~**~~***~~**~~**~~**" << endl;*/
  198. //SquareCube();
  199. //CalculateBMI(180, 64.5);
  200. //CalculateGasCost();
  201.  
  202. DrawingASquare();
  203. DrawingTShape();
  204. DrawingADiamond();
  205.  
  206.  
  207. return 0;
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement