Advertisement
DrAungWinHtut

menusystem.cpp

Dec 24th, 2024
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib> //system
  3.  
  4. using namespace std;
  5.  
  6. float calculateArea(float l, float w);
  7. float calculateGoldPrice(
  8.     int currentGoldPrice,
  9.     float kyat,
  10.     float pae,
  11.     float yway
  12. );
  13. void area();
  14. void gold();
  15. void prompt();
  16.  
  17. int main()
  18. {  
  19.    
  20.    
  21.     int ans = -1;
  22.     do {
  23.         prompt();
  24.         cin >> ans;
  25.  
  26.         switch (ans)
  27.         {
  28.         case 1:            
  29.             area();
  30.             break;
  31.         case 2:        
  32.             gold();
  33.             break;
  34.         case 3: exit(0); break;
  35.         default: cout << "invalid input, only 1,2,3: try again!" << endl;
  36.         }
  37.         system("pause");
  38.     } while (ans!=3);
  39.  
  40.     return 0;
  41. }
  42.  
  43.  
  44. float calculateArea(float l, float w) //float l = l;
  45. {  
  46.     return l * w;  
  47. }
  48.  
  49. float calculateGoldPrice(
  50.     int currentGoldPrice,
  51.     float kyat,
  52.     float pae,
  53.     float yway
  54. )
  55. {
  56.     float totalGoldWeight = kyat + (pae / 16) + (yway / 128);
  57.     return totalGoldWeight * currentGoldPrice;
  58.  
  59. }
  60.  
  61.  
  62. void area()
  63. {
  64.     float l = 0.0F;
  65.     float w = 0.0F;
  66.     cout << "enter w: ";
  67.     cin >> w;
  68.     cout << "enter l: ";
  69.     cin >> l;
  70.     cout << "area = " << calculateArea(w, l) << endl;
  71. }
  72.  
  73. void gold()
  74. {
  75.     int gp = 0;
  76.     float k = 0.0F;
  77.     float p = 0.0F;
  78.     float y = 0.0F;
  79.     cout << "enter current gold price: ";
  80.     cin >> gp;
  81.     cout << "enter kyat: ";
  82.     cin >> k;
  83.     cout << "enter pae: ";
  84.     cin >> p;
  85.     cout << "enter yway: ";
  86.     cin >> y;
  87.     cout << "total gold price  = " << calculateGoldPrice(gp, k, p, y) << endl;
  88. }
  89.  
  90. void prompt()
  91. {
  92.     system("cls");
  93.     cout << "1-area" << endl;
  94.     cout << "2-gold price" << endl;
  95.     cout << "3-exit" << endl;
  96.     cout << "choose 1,2,3: ";
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement