2016-09-22 5 views
-4

Ich versuche, einen Inflationsrechner zu bauen, aber es funktioniert nicht. Ich bin momentan außer Landes und benutze einen Schul-PC, damit alle Fehler auf Koreanisch erscheinen, ich habe sie übersetzt aber nicht ganz verstanden.Inflationsrate Rechner C++

#include <iostream> 
using namespace std; 

double inflationRate (double startingPrice, double currentPrice); 

int main() 
{ 
    double startingPrice, currentPrice; 
    char again; 

    do 
    { 
     cout << "enter the price of the item when you bought it: "; 
     cin >> startingPrice; 

     cout << "enter the price of the item today: "; 
     cin >> currentPrice; 

     cout << "the inflation Rate is: " << inflationRate(startingPrice, currentPrice) << "%"; 

     cout << "would you like to try another item (y/n)?"; 
     cin >> again; 

    }while((again == 'Y') || (again =='y')); 

    return 0; 
} 

double inflationRate(double startingPrice, double currentPrice) 
{ 
    return ((currentPrice - startingPrice)/startingPrice); 
} 

1> ------ Erstellen gestartet: Projekt: Testen, Konfiguration: Debug Win32 ------

1> Build gestartet: 2016.09.22 11.04: 39 AM

1> InitializeBuildStatus:

1> "Debug \ testing.unsuccessfulbuild" verbunden sind (berühren) a.

1> ClCompile:

1> Die Ausgabe ist auf dem neuesten Stand.

1> ManifestResourceCompile:

1> Die Ausgabe ist auf dem neuesten Stand.

1> LINK: Schwerwiegender Fehler LNK1123: Bei der Konvertierung in COFF ist ein Fehler aufgetreten. Oder eine beschädigte Datei ist falsch.

1>

1> konnte nicht erstellt werden.

1>

1> Abgelaufene Zeit: 00: 00: 00.08

========== Körperbau: 0 gelang, 1 schlug fehl, die letzte 0, 0 übersprungen == ========

+1

Sie beide haben eine Funktion und Variable mit dem Namen 'inflationRate' Ändern einer Sie – vu1p3n0x

+0

Sie können versuchen, translate.google verwenden und zeigen Sie uns diese Fehler – YakovL

Antwort

0

Sie deklarieren eine nutzlose Variable inflationRate anstatt die Funktion inflationRate aufzurufen. Ich denke, das ist das, was Sie wollen (Ich gehe davon aus dem # in der ersten Zeile fehlt ein Copy-Paste-Fehler wurde):

#include <iostream> 
using namespace std; 


double inflationRate (double startingPrice, double currentPrice); // <-- Missing semicolon! 


int main() // <-- Not void; use int. 
{ 
double startingPrice, currentPrice; // <-- Removed inflationRate variable. 
char again; 

do 
{ 
    cout << "enter the price of the item when you bought it: "; 
    cin >> startingPrice; 

    cout << "enter the price of the item today: "; 
    cin >> currentPrice; 

    cout << "the inflation Rate is: " << inflationRate(startingPrice, currentPrice) << "%"; // <-- Calling inflationRate 

    cout << "would you like to try another item (y/n)?"; 
    cin >> again; 

}while((again == 'Y') || (again =='y')); 

return 0; 

} 

double inflationRate(double startingPrice, double currentPrice) 
{ 
    return ((currentPrice - startingPrice)/startingPrice); 
} 
+0

danke! funktioniert jetzt – Fernanda