c++提问。

来源:百度知道 编辑:UC知道 时间:2024/06/17 11:21:44
某一城市规定。每月每人用水不超过2吨。则按每吨1.8元计算。若超过2吨,则超出部分加一倍收费。即每吨3.6元收费,用c++编程。

# include<iostream.h>
# include<math.h>
void main()
{
double x,y,n;
cin>>x>>n;
if(x/n<=2) y=1.8*x;
else if(x/n>2) y=1.8*(2*n)+3.6*(x-2*n);
cout<<x<<''<<n<<''<<y<<endl;
}

应该怎样修改啊

/*
1.Dev-cpp 4.9.9.2 compiler successfully

某一城市规定。每月每人用水不超过2吨。则按每吨1.8元计算。若超过2吨,则超出部分加一倍收费。即每吨3.6元收费,用c++编程。
*/

#include<iostream>
//# include<math.h>
using namespace std;
int main()
{
double price,quantity=0;
cout<<"Please input quantity of water use:";
cin>>quantity;
if(quantity<2)
{
price=1.8*quantity;
}
else if(quantity>2)
price=1.8*quantity+(quantity-2)*3.6;
else
cout<<"Sorry,Plz input correct number!"<<endl;
cout<<"Report: This month water fee is: "<<price<<"$"<<endl;
}

给你一个简单的。
#include <iostream.h>
void main()
{
double waterconsume,price;
cout<<"ÇëÊäÈë±¾ÔµÄÓÃË®Á¿:" ;
cin>