--------------------------------------------------------------------------------

I am tyring to write a simple program to display distance traveled. here are my instructions:

Write a program that asks the user for the speed of a vehicle (In miles per hour) and how many hours it has traveled. It should then use a loop to display the distance the vehicle has traveled for each hour of that time period. Her is an example of the output


What is the speed of the vehicle in mph? 40
How many hours has it traveled? 3

Hour Distance Traveled
--------------------------------------------------
1 40
2 80
3 120

Input validation:
Do not accept any negative number for speed and do not accept any value
less than one for time traveled.


The output should be formatted and aligned according to the above.

Here is my code so far:
Code:
CPP / C++ / C Code:
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int main ()
{
int speed, distance, time, a, b;
a=1;
b=a*speed;

cout << "Distance Program";                                         
cout << "\n\n\nWhat is the speed of the vehicle in mph?\n";         
cin >> speed;                                                       
cout << "\nHow many hours has it traveled?\n";       
cin >> time; 

if (time >1 && speed >0)
  
       cout << "\n\nHour                  Distance Traveled"; 
       cout << "\n--------------------------------------\n";
        
        while (a<= time)
                {
                  a++;
                  cout << "\n";
                  cout << a;                    
                  printf("                      ");
                  cout << b;
                  cout << "\n";
                  
                  }      
             return 0;

else   
    
      {
       cout << "\n\nYou have entered invalid data\n\n";
       system("pause");
       }
}
I keep getting the "expected primary-expression before 'else'" error and the "expected ";" before 'else'" error. Am I missing something very simple? Imay not know much about programming, but I thought this was straight-forward