fork(1) download
  1. // C++ Weight Finder
  2. // Values. a = height b = width c = depth/thickness d = material
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. string m;
  10. cout << "Enter Measuring Unit (mm or metres):\n";
  11. cin >> m;
  12.  
  13. double a;
  14. cout << "Enter Height:\n";
  15. cin >> a;
  16.  
  17. double b;
  18. cout<< "Enter Width:\n";
  19. cin >> b;
  20.  
  21. double area;
  22. area = a*b;
  23. cout << "Area Of Shape = " << area;
  24. if (m == "mm") {
  25. cout << " mm2" <<endl;
  26. }
  27. else {
  28. cout << " m2" <<endl;
  29. }
  30.  
  31. double c;
  32. cout << "\nEnter Depth/Thickness:\n";
  33. cin >> c;
  34.  
  35. double vol;
  36. vol = area*c;
  37. cout << "Volume Of Solid = " << vol;
  38. if (m == "mm") {
  39. cout <<" mm3" <<endl;
  40. }
  41. else {
  42. cout << " m3" <<endl;
  43. }
  44.  
  45. double w;
  46. string dens;
  47. cout << "\nEnter Material Used:\n";
  48. cin >> dens;
  49.  
  50. double s;
  51. double g;
  52. if (m=="mm"){
  53. s = 7.85;
  54. g = 0.05;
  55. }
  56. else {
  57. s = 7850;
  58. g = 50;
  59. }
  60.  
  61. if (dens == "steel") {
  62. w = vol*s;
  63. }
  64. if (dens == "grp") {
  65. w = vol*g;
  66. }
  67. cout << "The Weight Of The Solid = " << w << "Kg" << endl;
  68. return 0;
  69. }
Success #stdin #stdout 0s 4464KB
stdin
Standard input is empty
stdout
Enter Measuring Unit (mm or metres):
Enter Height:
Enter Width:
Area Of Shape = 0 m2

Enter Depth/Thickness:
Volume Of Solid = 0 m3

Enter Material Used:
The Weight Of The Solid = 6.95335e-310Kg