// Includes
#include "stdafx.h"
#include <iostream>
#include <conio.h>
usingnamespace std;
// Main Function
int main()
{
int speed;
int hours;
double totalmiles;
int a = 1;
cout << "This program allows the user to the speed and distance of a vehicle the display the total distance the vehicle went.\n\n";
cout << "Enter the speed of vehicle in MPH: ";
cin >> speed;
cout << "Enter the hours it traveled: ";
cin >> hours;
cout << "\n\n";
cout << "Hour, Speed, and Distance traveled" << endl;
while (a != hours)
{
totalmiles = speed * a;
cout << a << " " << speed << " " << totalmiles << endl;
a = a + 1;
}
_getch();
return 0;
}
I am missing something here, it works but it is buggy, like the enter speed of 40 and hours of 30, its suppose to print
1 40 40
2 40 80
3 40 120
but its buggy and i am only getting the first 2 hour and not the 3rd, any idea where the code is buggy at.