一个小小的问题
//The program will calculate the bill for the services requested.#include<iostream>
using namespace std;
bool mow(char mow);
bool small(char small);
bool application(char application_of_pesticides);
bool flower(char flower_bed_weeding);
bool tree (char tree_trimming);
float total(float TOTAL_BILL,float small,float application_of_pesticides,float flower_bed_weeding,float tree_trimming);
float TOTAL_BILL;
int main()
{
float mowing, small, application_of_pesticides,flower_bed_weeding,tree_trimming;
cout<<"Enter your choices as y or n!"<<endl;
cout<<"Mowing? (y/n)"<<endl;
cin>>mowing;
cout<<"Small? (y/n)"<<endl;
cin>>small;
cout<<"Application of Pesticides? (y/n)"<<endl;
cin>>application_of_pesticides;
cout<<"Flower Bed Weeding? (y/n)"<<endl;
cin>>flower_bed_weeding;
cout<<"Tree Trimming? (y/n)"<<endl;
cin>>tree_trimming;
TOTAL_BILL=total( TOTAL_BILL, small, application_of_pesticides,flower_bed_weeding,tree_trimming);
cout<<"Your bill is "<<TOTAL_BILL<<endl;
system ("pause");
return 0;
}
bool mow(char mow)
{
bool result;
if (mow=='y')
result=true;
if (mow=='n')
result=false;
return result;
}
bool small(char small)
{
bool result1;
if (small=='y')
result1=true;
if (small=='n')
result1=false;
return result1;
}
bool application(char application_of_pesticides)
{
bool result2;
if (application_of_pesticides='y')
result2=true;
if (application_of_pesticides='n')
result2=false;
return result2;
}
bool flower(char flower_bed_weeding)
{
bool result3;
if (flower_bed_weeding=='y')
result3=true;
if(flower_bed_weeding=='n')
result3=false;
return result3;
}
bool tree (char tree_trimming)
{
bool result4;
if (tree_trimming=='y')
result4=true;
if(tree_trimming=='n')
result4=false;
return result4;
}
float total(float TOTAL_BILL,float small,float application_of_pesticides,float flower_bed_weeding,float tree_trimming)
{
bool result1, result2, result3, result4;
if (result1=true)
const float small=25;
else
const float small=35;
if (result2=true)
const float application_of_pesticides=15;
else
const float application_of_pesticides=0;
if (result3=true)
const float flower_bed_weeding=10;
else
const float flower_bed_weeding=0;
if (result4=true)
const float tree_trimming=20;
else
const float tree_trimming=0;
TOTAL_BILL=small+application_of_pesticides+flower_bed_weeding+tree_trimming;
return TOTAL_BILL;
}
程序输出的时候有乱码……希望那个大虾帮帮忙啊~~
随便,希望在再说没有mow之后,可以直接问第三题~~