How do i get the constant value to be a value entered by the user. The only way i can get this to work is to make it a constant.
The program works fine for now. I just dont get why my exchange cannot use the value when its not a constant?????
Also i want to figure out how to get the exRate entered once in the loop instead of over and over.
Thanks in advance for your help.
Code:
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
class Exchange
{
public:
float exRate;
float BritishPound;
float USDollar;
};
void main()
{
cout << "Lets process 3 british pound amounts and convert to US dollars" << "\n";
int const values = 3;
if (values==0) {
cout << "Error with input! please run program again!";
}
Exchange test[values];
for(int i=0; i < values; i++)
{
cout << "Enter in British to US conversion rate: ";
cin >> test[i].exRate;
cout << "Enter British Value to convert: ";
cin >> test[i].BritishPound;
test[i].USDollar = (test[i].BritishPound * test[i].exRate);
}
cout << setw(10) << "\nExchange Rate " <<setw(15) << "British pounds to convert "
<< setw(10) << "US money " << "\n";
for(int j=0; j < values; j++)
{
cout<<setiosflags(ios::fixed | ios::showpoint)<<setprecision(2)
<< setw(3) << test[j].exRate<<setw(20)<< test[j].BritishPound
<<setw(30) << test[j].USDollar << "\n";
}
}