| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 324 人关注过本帖
标题:一个小小的问题
只看楼主 加入收藏
Denmark
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-10-24
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:3 
一个小小的问题
//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之后,可以直接问第三题~~
搜索更多相关主题的帖子: 小小的 
2010-11-03 13:04
Denmark
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-10-24
收藏
得分:0 
谢谢大虾们了~~
2010-11-03 13:05
shafeilong
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:236
专家分:1434
注 册:2009-3-21
收藏
得分:20 
char mowing, small, application_of_pesticides,flower_bed_weeding,tree_trimming; //定义错误罢了
2010-11-03 13:08
Denmark
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-10-24
收藏
得分:0 
可是,有两个问题
1.当mow输入n的时候,没有直接跳过第2问
2.最终输出的答案也不是很对
2010-11-03 13:27
快速回复:一个小小的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018135 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved