Hey Im trying to do a currency converter for USD and EUR. The program has to ask first what conversion is desired, then what the conversion rate is, and then it shows the first ten values in a tabular form. When I run the program, it shows the first ten values but the converted value is off by 1. In other words, the converted converted value for 2 goes to 1 and the one for 3 goes to 2 and so on. Here´s what I have:
// Intro to Programming: Assigment #1
#include <iostream>
using namespace std;
int option;
double dollars=1;
double euros=1;
double rate;
int main()
{
cout << "Please select which conversion is desired: " << endl;
cout << "1. USD->EUR" << endl;
cout << "2. EUR->USD" << endl;
cin >> option;
cout << "Please enter the conversion rate, " << endl;
cout << "For example: 1EUR=1.4USD" << endl;
cin >> rate;
Track the value of euro and dollars a line at a time and I think you will find the first value converted is 2, not 1 as you expect because dollars++ and euros++ are a bit too early in the proceedings.
Print out the values as you proceed through each line of the while loop. You can do it manually with a pencil and paper. You should see your problem straight away.