Feb 14, 2016 at 7:17pm UTC
Why won't this compute? i have been working all day trying to get it to compute correctly!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
//============================================================================
// Name : Currency
// Author : Corey Woods
// Professor :
// Date :
// Description : This program will convert 100 U.S dollars to Zambian Kwacha,
// Icelandic Krona, and Swedish Krona.
//============================================================================
#include <iostream>
#include <iomanip>
using namespace std;
const double ZAMBIAN_KWACHA_PER_DOLLARS = 11.25;
const double ICELANDIC_KRONA_PER_DOLLARS = 126.80;
const double SWEDISH_KRONA_PER_DOLLARS = 8.40;
int selection = 0;
double dollar;
double dollarToZambianKwacha(double zambianKwacha)
{
cout << "Please input the U.S. Dollar amount for Zambian Kwacha conversion: $" ;
cin >> dollar;
cout << "Your Zambian Kwacha conversion is: " << fixed << setprecision(2) << dollar << endl;
zambianKwacha = dollar * ZAMBIAN_KWACHA_PER_DOLLARS;
return zambianKwacha;
}
double dollarToIcelandicKrona(double icelandicKrona)
{
cout << "Please input the U.S. Dollar amount for Icelandic Krona conversion: $" ;
cin >> dollar;
cout << "Your Icelandic Krona conversion is: " << fixed << setprecision(2) << dollar << endl;
icelandicKrona = dollar * ICELANDIC_KRONA_PER_DOLLARS;
return icelandicKrona;
}
double dollarToSwedishKrona(double swedishKrona)
{
cout << "Please input the U.S. Dollar amount for Swedish Krona conversion: $" ;
cin >> dollar;
swedishKrona = dollar * SWEDISH_KRONA_PER_DOLLARS;
cout << "Your Swedish Krona conversion is: $" << fixed << setprecision(2) << swedishKrona << endl;
return swedishKrona;
}
double getUserChoice()
{
while (true )
{
cout << "Please select from the following options: " << endl;
cout << "Option 1 -> Dollar to Zambian Kwacha Conversion" << endl;
cout << "Option 2 -> Dollar to Icelandic Krona Conversion" << endl;
cout << "Option 3 -> Dollar to Swedish Krona Conversion" << endl;
cout << "Option 4 -> Exit" << endl;
cin >> selection;
cout << endl;
if (selection == 1)
{
dollarToZambianKwacha(zambianKwacha);
}
else if (selection == 2)
{
dollarToIcelandicKrona(icelandicKrona);
}
else if (selection == 3)
{
dollarToSwedishKrona(swedishKrona);
}
else if (selection == 4)
{
cout << "Goodbye! Have a nice day!" << endl;
abort();
}
else
{
cout << "Incorrect selection! Please try again." << endl << endl;
}
}
return selection;
}
int main()
{
getUserChoice();
dollarToZambianKawacha(zambianKwacha);
dollarToIcelandicKrona(icelandicKrona);
dollarToSwedishKrona(swedishKrona);
return 0;
}
Last edited on Feb 14, 2016 at 7:20pm UTC
Feb 14, 2016 at 7:22pm UTC
Line 69. The variable zambianKwacha does not exist inside that function.
Read the error messages from the compiler. They exist for a reason.
Feb 14, 2016 at 7:23pm UTC
Edit: Forget everything that was in this post I misread.
Last edited on Feb 14, 2016 at 7:34pm UTC
Feb 14, 2016 at 7:29pm UTC
its not returning the correct conversion though?
Feb 14, 2016 at 7:42pm UTC
(Forget my last post)
Your problem, like @Moschops stated, is that the variables you are using does not exist. swedishKrona, icelandicKrona and zambianKwacha does not exist, you havent created them. You need to create these variables before using them, which Im sure you already know. You're also not using the arguments you pass to the functions.
Last edited on Feb 14, 2016 at 7:42pm UTC
Feb 14, 2016 at 8:03pm UTC
How do you output this all to a file