Advertisement
Guest User

Untitled

a guest
Oct 24th, 2010
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1.  
  2. // Brian from HF
  3. // Brian from HF
  4. #include <iostream>
  5. #include <cmath>
  6. // Brian from HF
  7. // Brian from HF
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.  
  13. cout << "/==============================================================================/" << endl;
  14. cout << "Welcome to Brian's Calculator. More options will be added and eventually a GUI.\n";
  15. cout << "/==============================================================================/" << endl;
  16.  
  17. int choice = 0;
  18. while (choice < 100) {
  19. cout << "Please select one of the following: \n";
  20.  
  21. cout << "1. C to F.\n";
  22. cout << "2. F to C.\n";
  23. cout << "3. Finding Volume.\n";
  24. cout << "4. Addition. \n";
  25. cout << "5. Subtraction. \n";
  26. cout << "6. Multiplication. \n";
  27. cout << "7. Division. \n";
  28. cout << "----------\n";
  29.  
  30. cin >> choice;
  31.  
  32. switch(choice)
  33. {
  34. float C;
  35. float F;
  36. case 1:
  37. cout << "Please enter the degrees in celsius: ";
  38. cin >> C;
  39.  
  40. F = 9 / 5 * (C + 32);
  41.  
  42. cout << "Temperature in Fahrenheit: " << F << endl;
  43.  
  44. break;
  45.  
  46. case 2:
  47. cout << "Please enter the degrees in farehenheit: \n";
  48.  
  49. cin >> F;
  50.  
  51. C = (F-32) * 5/9;
  52.  
  53. cout << "Temperature in Celcius: " << C << endl;
  54.  
  55. break;
  56.  
  57. case 3:
  58. double volume;
  59. double width;
  60. double height;
  61. double length;
  62. cout << "Finding the volume of a shape:";
  63.  
  64. cout << endl << "Please enter the width of a shape: ";
  65. cin >> width;
  66.  
  67. cout << endl << "Please enter the height of that shape: ";
  68. cin >> height;
  69.  
  70. cout << endl << "Please enter the length of that shape: ";
  71. cin >> length;
  72.  
  73. volume = width * height * length;
  74.  
  75. cout << "The volume of " << width << " (width) times " << height << " (height) times " << length << " (length) equals: "<< volume << endl;
  76.  
  77. break;
  78. // brian from hf
  79. {
  80. case 4:
  81. int a;
  82. int b;
  83. int c;
  84. cout << "Welcome to the Addition Section of the Calculator.\n";
  85. cout << "Please enter one integer: " << endl;
  86. cin >> a;
  87. cout << "Please enter a second integer to be added to " << a << endl;
  88. cin >> b;
  89.  
  90. c = a + b;
  91.  
  92. cout << "The answer is: " << c << endl;
  93.  
  94. break;
  95.  
  96. case 5:
  97.  
  98. cout << "Welcome to the Subtraction Section of the Calculator.\n";
  99. cout << "Keep in mind that in subtraction, whether you do the larger first or the smaller first you will always end up with the same absolute value. If you choose to do 10-20, the answer will be -10. The absolute value of which is 10. 10 from 0. As is 20-10.\n";
  100. cout << "Please enter the larger integer: " << endl;
  101. cin >> a;
  102. cout << "Please enter the smaller integer: " << endl;
  103. cin >> b;
  104.  
  105. c = a - b;
  106.  
  107. cout << "The answer is " << c << endl;
  108.  
  109. break;
  110.  
  111. case 6:
  112.  
  113. cout << "Welcome to the Multiplication Section of the Calculator.\n";
  114. cout << "Please enter one number: ";
  115. cin >> a;
  116. cout << "Please enter the second number: ";
  117. cin >> b;
  118.  
  119. c = a * b;
  120.  
  121. cout << "The answer is: " << c << endl;
  122. break;
  123. }
  124. {
  125. case 7:
  126. float a;
  127. float b;
  128. float c;
  129. cout << "Welcome to the Division Section of the Calculator.\n";
  130. cout << "Please enter the divisor: \n";
  131. cin >> a;
  132. cout << "Please enter the dividend: \n";
  133. cin >> b;
  134.  
  135. c = a/b;
  136.  
  137. cout << "The answer is: " << c << endl;
  138.  
  139. break;
  140. }
  141. default:
  142. cerr << "Invalid Choice" << endl;
  143. break;
  144. }
  145. }
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement