Good afternoon everybody, I've been trying to made converter of values entered.
Basic idea is to make converter which converts a lot of values different units.
But it prints out and converts only last value I've entered, and in the end I'm getting error : Vector subscript out of range.
int main()
{
vector <double> values;
vector <string> units;
double value = 0;
string unit;
for(int x =0; x<100; x++) /*for loop made to read input into value and unit, then push it into vectors and
to print out the result */
cin >> value >> unit;
values.push_back(value);
units.push_back(unit);
if (unit == "m")
cout << value / 100 << "m" << '\n';
else if (unit == "cm")
cout << value * 100 << "cm" << '\n';
else if (unit == "in")
cout << value *2.54 << "cm" << '\n';
else if (unit == "ft")
cout << value * 12 << "in" << '\n';
else
cout << "I don't know this unit" << '\n';
//here I'm trying to print out all the values entered
for (int x = 0; x < 100; x++) {
cout << values[x] << endl;
cout << units[x] << endl;
}