2014-01-08 120 views
0

我需要帮助尽管我通过ideone传递代码,它似乎工作,它是数据类型可能吗?我需要帮助ttlTx变量显示为0血流冲刷的输出。帮助赞赏!错误的输出简单的税计算器

/* 


*/ 
//Libraries 
#include <cstdlib> 
#include <iostream> 

using namespace std; 

//Global Constants 

//Functioning Prototypes 

//Execution Begins Here 
int main(int argc, char **argv){ 
    //Variables 
    float purchse, ttlTx, stateTx, cntyTx, total; 

    //Process 
    purchse= 52; 
    stateTx= 0.04; //state tax 
    cntyTx= 0.02; //county tax 
    ttlTx= purchse*(stateTx + cntyTx); //total tax 
    total = purchse+ttlTx; 

    //output 
    cout<<"the total tax on a $"<< purchse<<" is $"<< 
     ttlTx<<endl; 
    cout<<"which brings the total to $" << total<<endl; 

    //Exit Stage Right 
    system("PAUSE"); 
    return EXIT_SUCCESS; 
} 
+0

流血?那是什么? – bmargulies

+0

Bloodshed Dev-C++,IDE - 请参阅http://www.bloodshed.net/devcpp.html。 – paxdiablo

+0

对不起,我的意思是DEV-C++,Bloodshed是软件的名称 – noobUser

回答

0

有没有错代码你粘贴在我的gcc编译器,我得到:

the total tax on a $52 is $3.12 
which brings the total to $55.12 

预期。

由于DEVC++使用MinGW的,它也使用gcc编译器,我无法想象任何大于0.1的版本,将不得不,严重:-)

因此它几乎肯定的一些环境问题的错误描述。 DevC++也没有像其他一些IDE一样活跃或者得到很好的支持(尽管这是我的观点),所以我倾向于建议人们使用CygWin(如果他们不关心IDE)或Code::Blocks(如果他们这样做的话)。

0

你的程序工作正常。我认为你的ID有问题。程序中没有错误。

enter image description here