(1)编写一函数,当输入价格和数量时,可以计算总价,当输入价格和数量以及折扣时,能够计算打折以后的销售总价,并输出
(2)要求写出主函数能够实现调用
#include<iostream>
using namespace std;
double total_price(double x, double y)
{
return x*y;
}
double total_price(double x, double y,double z)
{
return x*y*z;
}
int main()
{
double price,amount,discount;
cout<<"Enter price and amount:";
cin>>price>>amount;
cout<<"The total price is "<<total_price(price,amount)<<endl;
cout<<"Enter price ,amount and discount:";
cin>>price>>amount>>discount;
cout<<"The total price is "<<total_price(price,amount,discount)<<endl;
return 0;
}