Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib> //system
- using namespace std;
- float calculateArea(float l, float w);
- float calculateGoldPrice(
- int currentGoldPrice,
- float kyat,
- float pae,
- float yway
- );
- void area();
- void gold();
- void prompt();
- int main()
- {
- int ans = -1;
- do {
- prompt();
- cin >> ans;
- switch (ans)
- {
- case 1:
- area();
- break;
- case 2:
- gold();
- break;
- case 3: exit(0); break;
- default: cout << "invalid input, only 1,2,3: try again!" << endl;
- }
- system("pause");
- } while (ans!=3);
- return 0;
- }
- float calculateArea(float l, float w) //float l = l;
- {
- return l * w;
- }
- float calculateGoldPrice(
- int currentGoldPrice,
- float kyat,
- float pae,
- float yway
- )
- {
- float totalGoldWeight = kyat + (pae / 16) + (yway / 128);
- return totalGoldWeight * currentGoldPrice;
- }
- void area()
- {
- float l = 0.0F;
- float w = 0.0F;
- cout << "enter w: ";
- cin >> w;
- cout << "enter l: ";
- cin >> l;
- cout << "area = " << calculateArea(w, l) << endl;
- }
- void gold()
- {
- int gp = 0;
- float k = 0.0F;
- float p = 0.0F;
- float y = 0.0F;
- cout << "enter current gold price: ";
- cin >> gp;
- cout << "enter kyat: ";
- cin >> k;
- cout << "enter pae: ";
- cin >> p;
- cout << "enter yway: ";
- cin >> y;
- cout << "total gold price = " << calculateGoldPrice(gp, k, p, y) << endl;
- }
- void prompt()
- {
- system("cls");
- cout << "1-area" << endl;
- cout << "2-gold price" << endl;
- cout << "3-exit" << endl;
- cout << "choose 1,2,3: ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement