I am actively working on a C++ currency transfer protocol. Yep - a nice, easy and basic start. Anyway, I have a few if statements that for some reason are always running as true. When I try and remove the semi-colons after the if's nothing runs - even if the statements are true...
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
char fromcr[3];
double amount;
char tocr[3];
char GBP[3];
char EUR[3];
char USD[3];
char INR[3];
double EUR1 = 1.12;
double USD1 = 1.32;
double INR1 = 90.48;
double converted;
char name;
int main()
{
cout << "What are the 3 letters of your starting currency? ";
cin >> fromcr;
cout << "How much do you want to convert? Format: 00.00 - no sign at beginning - ";
cin >> amount;
cout << "What are the 3 letters of your ending currency? - ";
cin >> tocr;
if (fromcr == "GBP");
{
if (tocr == "GBP");
{
converted = (amount);
cout << "Coverted amount: " << converted;
}
if (tocr == "EUR");
{
converted = (amount * EUR1);
cout << "Coverted amount: " << converted;
}
if (tocr == "USD");
{
converted = (amount * USD1);
cout << "Coverted amount: " << converted;
}
if (tocr == "INR");
{
converted = (amount * INR1);
cout << "Coverted amount: " << converted;
}
}
}
Aucun commentaire:
Enregistrer un commentaire