Hello guys. I'm creating a program that basically inputs the speed of a vehicle and speed limit and determines what type of fine they will get if they are speeding at all. My problem seems to be with the IF statement. I'm having trouble with it. For some reason, my formulas aren't sticking and the fine isn't being displayed.... I would love if someone could point me in the right direction. Thanks for your help.
Code:
/**********************************************************************
*Program Name : Speed Trap
*Program Description: Write a program that will determine how much to fine
*a speeder.
*
*BEGIN Lab05 - Speed Trap
* Input Vehicle Speed
* Input Speed Limit
* Clear the screen
* Calc Amount Speeding
* If(Vehicle Is Speeding)
* If(Amount Speeding Is In Low Range)
* Fine Equals Minimum Fine
* Else If(Amount Speeding Is In Middle Range)
* Fine Equals Middle Fine
* Else
* Fine Equals Max Fine
* End If
* Display Speeding Message
* Display Fine
* Else Not Speeding
* Display Not Speeding Message
* End If
*END Lab05 - Speed Trap
**********************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//local constants
const int MIN_BOUND = 5;
const int MAX_BOUND = 15;
const int MIN_FINE = 0;
const int MID_FINE = 50;
const int MAX_FINE = 100;
//local variables
int Veh_Speed;
int Speed_Lim;
float Amt_Speed;
float Fine_Amt;
/************************start main program************************/
// Input Vehicle Speed
cout << "Enter the Vehicle Speed : ";
cin >> Veh_Speed;
// Input Speed Limit
cout << "Enter the Speed Limit: ";
cin >> Speed_Lim;
//Clear the screen
system("cls");
// Calc Amount Speeding
Amt_Speed = Veh_Speed - Speed_Lim;
// If (Vehicle Is Speeding)
if( Amt_Speed > Speed_Lim )
if( Amt_Speed >= MIN_BOUND && Amt_Speed < MAX_BOUND )
Fine_Amt = MIN_FINE;
else if( Amt_Speed >= MAX_BOUND && Amt_Speed > MAX_BOUND )
Fine_Amt = MID_FINE;
else
Fine_Amt = MAX_FINE;
// End IF
// Display Speeding Information
cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(1);
cout << "\n\n\n\n";
cout << setw(56) << " Speed Trap " << "\n\n\n\n";
cout << setw(43) << "Fine ($) " << setw(9) << Fine_Amt << "\n\n";
cout << setw(43) << "Amount Speeding (mph) " << setw(9) << Amt_Speed << "\n\n";
cout << "\n\n\n\n\n\n\n";
//pause the output screen for viewing
system("pause");
return 0;
} // end if main function