2015-09-17 52 views
0

我正在寫這個相當簡單的代碼,但突然我開始得到這個「Id返回1退出狀態錯誤」。我對該代碼做出的最新更改是在顯示函數中添加了所有「endl」。我不知道該怎麼做,請幫助「Id返回1退出狀態」錯誤C++

#include <iostream> 
#include <iomanip> 
#include <cmath> 
using namespace std; 

void getOrder(double&spools, double&stock, double&charge); 
void displayOrder(double spools, double stock, double charge); 


int main() 
{ 
    double spools; 
    double stock; 
    double charge; 
    getOrder(spools, stock, charge); 
    displayOrder(spools, stock, charge); 
    system("pause");//come back to these v2v lines 
    return 0; 
} 

void getOrder(double&spools, double&stock, double&charge) 
{ 
    charge= 0; 
    char extra; 
    double extraCharge; 
    cout<<"How many spools were ordered?:"; 
    cin>>spools; 
    while(spools<1){ 
     cout<<"Entry must be greater than 1...: "; 
     cin>> spools; 
    } 
    cout<<"How many spools are in stock?:"; 
    cin>>stock; 
    while(stock<0){ 
     cout<<"Entry must be greater than 0...: "; 
     cin>> stock; 
    } 
    cout<<"Are there any special shipping and handling chsrges?(y for yes, n for no):"; 
    cin>>extra; 
    if(extra=='y'|| extra=='Y'){ 
     cout<<"Enter the special charge amount:$"; 
     cin>>extraCharge; 
     while(extraCharge<0){ 
     cout<<"Entry must be greater than 0... :"; 
     cin>> extraCharge; 
     } 
    } 

    charge=extraCharge; 
//no returns needed because reference variables 
} 

void displayOrder(double spools, double stock, double charge=10) 
{ 
    double backOrder=spools-stock; 
    double spoolsOrdered; 
    double subTotal=spools*100; 
    double shipping; 
    double total=subTotal+charge; 
    double ready=stock-spools; 

    //spools ready to ship from current stock 
    cout<<"There are"<<ready<<"spools ready to be shipped."<<endl; 
    //if statement for BACKORDERRRrr 
    if(spools>stock) 
    { 
     backOrder=spools-stock; 
     cout<<"There are"<<ready<<"spools ready to be shipped."<<endl; 
     cout<<"There are"<<backOrder<<"spools on back order."<<endl; 
     cout<<"Subtotal: $"<<subTotal<<endl; 
     cout<<"Shipping & Handling charge:$"<<charge<<endl; 
     cout<<"The total fee for this transaction is:$"<<total<<endl; 

    } 
    else 
    { 
     cout<<"There are"<<ready<<"spools ready to be shipped."<<endl; 
     cout<<"Subtotal: $"<<subTotal<<endl; 
     cout<<"Shipping & Handling charge:$"<<charge<<endl; 
     cout<<"The total fee for this transaction is:$"<<total<<endl; 
    } 
} 
+0

什麼是完整的錯誤? – Pradhan

+0

什麼是您的操作系統和編譯器?它在刪除系統(「暫停」)後在我的系統(g ++ 4.8,ubuntu)中運行。 – Brightshine

+1

dev C++和windows – Muffen

回答

1

我剛剛在Dev C++上試過你的代碼,它運行得很好。 此錯誤的一個可能的原因是來自上一次運行的.exe文件仍然在某處。關閉它並重試。

相關問題