1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include <iostream>
#include <iomanip>
using namespace std;
class FruitJuice
{
private:
float water,mango,orange,apple,watermelon,lemon,price;
public:
void makeJuice(float w,float m,float o,float a,float wm,float l)
{
water = w;
mango = m;
orange = o;
apple = a;
watermelon = wm;
lemon = l;
}
void display()
{
float total;
total = water + mango + orange + apple + watermelon + lemon;
cout<<":::Your juice details"<<endl;
cout<<"------------------------------------"<<endl;
cout << "Water : " << water << "ml" << endl;
cout << "Mango : " << mango << "ml" << endl;
cout << "Orange : " << orange << "ml" << endl;
cout << "Apple : " << apple << "ml" << endl;
cout << "Watermelon : " << watermelon << "ml" <<endl;
cout << "Lemon : " << lemon << "ml" << endl;
cout << ":::Total ml : " << total << "ml" << endl;
}
void calcPayment()
{
float price = 0.00;
float totalprice;
if(water > 0 || mango > 0 || orange > 0 || apple > 0 || watermelon > 0 || lemon > 0)
{
totalprice = price + (water * 0.00) + (mango * 0.10) + (orange * 0.15) + (apple * 0.15) + (watermelon * 0.12) + (lemon * 0.05);
}
cout << ":::Thank you, the price of your drink is RM "<< setiosflags(ios::fixed) << setprecision(2) << totalprice << endl;
}
};
int main()
{
FruitJuice J;
float water, mango, orange, apple, watermelon, lemon;
cout << ".....Making Fruit Juice.............." << endl;
cout << "Set amount of water in ml : ";
cin >> water;
cout << "Set amount of mango in ml : ";
cin >> mango;
cout << "Set amount of orange in ml : ";
cin >> orange;
cout << "Set amount of apple in ml : ";
cin >> apple;
cout << "Set amount of watermelon in ml : ";
cin >> watermelon;
cout << "Set amount of lemon in ml : ";
cin >> lemon;
cout <<"TQ. Please wait a while..."<< endl;
J.makeJuice(water, mango, orange, apple, watermelon, lemon);
J.display();
J.calcPayment();
return 0;
}
|