1 thought on “C version automatic water sales source code”
Connie
#include "iOSTREAM" #Include "String" USING NAMESPACE STD; CLASS { float input_money; public: void getMoney (); float mony_from_buyer (); void return_money (float change); void clear (); (); ~ ( ); }; class goodsinfo { private: string name; float price; intnted; public : goodsinfo (); ~ goodsinfo (); void set_goods (string n, float p, int T); string goods_name (); (); int Goods_total (); void goods_disp (); }; class { private: n n n n n n n Moneyctr; goodsinfo v_goods [5]; public: (); ~ (); void showmenu (); void (); boy goodsitem (int); void return_allmoney (); }; :: () n { input_money = 0.0F;
} ::) { } nvoid :: getmoney () { float money; cout u003Cu003C "A set of warm reminders u003C*_*>-> Please invest in the coin" u003Cu003C Endl; Cin >> Money; input_money = input_money Money; COUT u003Cu003C "The amount you invest is a set of warm mention Show u003C*_*>: u003Cu003C Input_Money u003Cu003C Endl; } float :: money_from_buyer () n { reTurn input_money; n} void :: Clear () { input_money = 0.0F; } void :: return_money { count u003C u003C"A set of warm tips u003C*_*>nFind zero "u003Cu003C CHANGE u003Cu003C" u003Cu003C Endl; } goodsinfo :: goodsinfo () { name = "" "; f; toTal = 0; } goodsinfo :: ~ goodsinfo () n { } void Goodsinfo :: SET_GOODS (String N, Float P, int T) { name = n; price = p; toTal = t; } string goodsinfo :: goods_name () r r r r r r r r r r r r r r r r r n {{ return name;
} void :: showmenu () // Display operating interface { n { COUT u003Cu003C "" A set of warm reminders u003C*_*>-> The amount you invest is "u003Cu003C MoneyCtr.Money_FROM_BUYER ()" u003Cu003C "u003Cu003C Endl; " "" Reminder u003C*_*>-> Please select the product code: "u003Cu003C endl; for (int i = 0; i u003C5; i ) { cout u003Cu003C i u003C u003C"" u003Cu003C v_goods [i] .goods_na me () u003Cu003C "u003Cu003C v_goods [i] .goods_price () u003Cu003C" "u003Cu003C Endl; } cout u003Cu003C" 5 refund and exit "u003Cu003C ENDL; } void :: () { cout u003Cu003C "" A set of warm reminders u003C*_*>-> This machine only accepts ten yuan, five yuan, binary, one yuan , 0.5 yuan coins or banknotes "u003Cu003C Endl; MoneyCTR.GetMoney (); } Bool :: goodsitem (int Select) { int number = v_goods [select] .goods_total (); if (number> 0) { if (MoneyCTR.Money_Buyer ()> = v_goods_price ()) // If the money is enough { float Change = MoneyCtr.Money_FROM_BUYER ()-v_goods [select] .goods_price (); cout u003Cu003C "You chose" u003Cu003C v_goods [select].. goods_name () u003Cu003C "Please take things" u003Cu003C endl; if (Change> 0) { moneyctr.return_money (Change); } n n n n n n n R n Return true; } else { cout u003Cu003C "" A set of warm reminder u003C*_*>-> Your amount is insufficient "u003Cu003C Endl; } } else { cout u003Cu003C "" A set of warm tips u003C*_*>-> The drink has been sold "u003Cu003C Endl; } Return false; } void :: return_allmoney () { cout u003Cu003C "refund" u003Cu003C MoneyCtr.Money_buyer () u003Cu003C "" "" "" Yuan Yuan Yuan Yuan "u003Cu003C ENDL; }
void main () { dri; string buf; bool go_on (true), cash_on (True), Got_it (TRUE); Cout u003Cu003C "***** ********** Welcome to use a set of automatic beverage vending machines. n { While (cash_on) { drai. yes or no) "; cin >> buf; if (buf ==" n "|| buf ==" no ") { cash_on = false; } } dri.showmenu (); cin >> buf; int seict = atoi (buf.c_str ()); (Select == 5) { dri.return_allmoney (); go_on = false; } else r { get_it = Dri.GoodSitem (Select); if (GOT_IT) { go_on = false; } el n { cout u003Cu003C "A set of warm tips u003C*_*>-> Do you need other drinks? (Yes or no)"; cin >> buf; if (buf == "y" || buf == "yes") { cash_on = true; } else { dri.return_allmoney (); go_on = false; } } } cout u003Cu003C "Thank you for using" u003Cu003C endl; } n}
#include "iOSTREAM"
#Include "String"
USING NAMESPACE STD;
CLASS
{
float input_money;
public:
void getMoney ();
float mony_from_buyer ();
void return_money (float change);
void clear ();
();
~ ( );
};
class goodsinfo
{
private:
string name;
float price;
intnted;
public :
goodsinfo ();
~ goodsinfo ();
void set_goods (string n, float p, int T);
string goods_name (); ();
int Goods_total ();
void goods_disp ();
};
class
{
private:
n n n n n n n Moneyctr;
goodsinfo v_goods [5];
public:
();
~ ();
void showmenu ();
void ();
boy goodsitem (int);
void return_allmoney ();
};
:: () n {
input_money = 0.0F;
}
::)
{
}
nvoid :: getmoney ()
{
float money;
cout u003Cu003C "A set of warm reminders u003C*_*>-> Please invest in the coin" u003Cu003C Endl;
Cin >> Money;
input_money = input_money Money;
COUT u003Cu003C "The amount you invest is a set of warm mention Show u003C*_*>: u003Cu003C Input_Money u003Cu003C Endl;
}
float :: money_from_buyer () n {
reTurn input_money;
n}
void :: Clear ()
{
input_money = 0.0F;
}
void :: return_money
{
count u003C u003C"A set of warm tips u003C*_*>nFind zero "u003Cu003C CHANGE u003Cu003C" u003Cu003C Endl;
}
goodsinfo :: goodsinfo ()
{
name = "" "; f;
toTal = 0;
}
goodsinfo :: ~ goodsinfo () n {
}
void Goodsinfo :: SET_GOODS (String N, Float P, int T)
{
name = n;
price = p;
toTal = t;
}
string goodsinfo :: goods_name () r r r r r r r r r r r r r r r r r n {{
return name;
}
float goodsinfo :: goods_price () n {
return price;
} nint goodsinfo :: goods_total ()
{
reTurn toTal;
}
void goodsinfo :: goods_disp () n {
cout u003Cu003C " name u003Cu003C "product unit price" u003Cu003C PRICE u003Cu003C "inventory" u003Cu003C Total u003Cu003C Endl;
}
:: () r {
v_goods [0] .set_goods ("Meinian Da", 3,20);
v_goods [1] .set_goods ("bitter coffee", 5,10);
v_goods [2] .set_goods ("" " Wahaha pure water ", 1.5,20);
v_goods [3] .set_goods (" Youlemei ", 2.5,30);
v_goods [4] .set_goods (" Pepsi ", 2.5,00 );
}
::)
{
}
void :: showmenu () // Display operating interface
{ n {
COUT u003Cu003C "" A set of warm reminders u003C*_*>-> The amount you invest is "u003Cu003C MoneyCtr.Money_FROM_BUYER ()" u003Cu003C "u003Cu003C Endl;
" "" Reminder u003C*_*>-> Please select the product code: "u003Cu003C endl;
for (int i = 0; i u003C5; i )
{
cout u003Cu003C i u003C u003C"" u003Cu003C v_goods [i] .goods_na me () u003Cu003C "u003Cu003C v_goods [i] .goods_price () u003Cu003C" "u003Cu003C Endl;
}
cout u003Cu003C" 5 refund and exit "u003Cu003C ENDL;
}
void :: ()
{
cout u003Cu003C "" A set of warm reminders u003C*_*>-> This machine only accepts ten yuan, five yuan, binary, one yuan , 0.5 yuan coins or banknotes "u003Cu003C Endl;
MoneyCTR.GetMoney ();
}
Bool :: goodsitem (int Select)
{
int number = v_goods [select] .goods_total ();
if (number> 0)
{
if (MoneyCTR.Money_Buyer ()> = v_goods_price ()) // If the money is enough
{
float Change = MoneyCtr.Money_FROM_BUYER ()-v_goods [select] .goods_price ();
cout u003Cu003C "You chose" u003Cu003C v_goods [select].. goods_name () u003Cu003C "Please take things" u003Cu003C endl;
if (Change> 0)
{
moneyctr.return_money (Change);
}
n n n n n n n R n Return true;
}
else
{
cout u003Cu003C "" A set of warm reminder u003C*_*>-> Your amount is insufficient "u003Cu003C Endl;
}
}
else
{
cout u003Cu003C "" A set of warm tips u003C*_*>-> The drink has been sold "u003Cu003C Endl;
}
Return false;
}
void :: return_allmoney ()
{
cout u003Cu003C "refund" u003Cu003C MoneyCtr.Money_buyer () u003Cu003C "" "" "" Yuan Yuan Yuan Yuan "u003Cu003C ENDL;
}
void main ()
{
dri;
string buf;
bool go_on (true), cash_on (True), Got_it (TRUE);
Cout u003Cu003C "***** ********** Welcome to use a set of automatic beverage vending machines. n {
While (cash_on)
{
drai. yes or no) ";
cin >> buf;
if (buf ==" n "|| buf ==" no ")
{
cash_on = false;
}
}
dri.showmenu ();
cin >> buf;
int seict = atoi (buf.c_str ()); (Select == 5)
{
dri.return_allmoney ();
go_on = false;
}
else r {
get_it = Dri.GoodSitem (Select);
if (GOT_IT)
{
go_on = false;
}
el n {
cout u003Cu003C "A set of warm tips u003C*_*>-> Do you need other drinks? (Yes or no)";
cin >> buf;
if (buf == "y" || buf == "yes")
{
cash_on = true;
}
else
{
dri.return_allmoney ();
go_on = false;
}
}
}
cout u003Cu003C "Thank you for using" u003Cu003C endl;
} n}