I'm a beginner at programming and I'm trying to make a Kilometer and Miles converter application. I'm using codeblocks for my code. Choice 2 keeps giving me 0 as the result. Here's the exact code I'm typing:
#include <iostream>
using namespace std;
double choice, value1, result;
// I'm sure I messed up somewhere after this:
double value2 = .621371;
double value3 = 1.609344;
// Are these two lines ^ supposed to be here?
int main()
{
while (true) {
cout << "1. Kilometers to Miles" << endl;
cout << "2. Miles to Kilometers" << endl;
cout << "3. Exit the Application" << endl;
cout << "Please enter a choice: ";
cin >> choice;
if (choice == 3)
break;
cout << "Please enter the first value: ";
cin >> value1;
// This if statement keeps giving me 0:
if (choice == 2)
result = value1 * value2;
// I believe this part here is okay:
else if (choice == 3)
result = value1 / value3;
cout << "The result is: " << result << endl;
}
}