1. ## Beginner Programmer looking for help on project please

I am continually looking over my notes and book trying to figure this out but i cant seem to find what i need.

the project is to compile a automated speeding ticket

[Note: Checkpoint A and B are always 5 miles apart]
Ticket prices are calculated as follow: base + fee*<number of mph over the speed limit>. The base is \$150 and the fee per mph over the speed limit is \$5. Time is kept in the number of minutes past midnight, so 10AM is 10hours * 60 minutes = 600, 10:30AM = 630, 10PM = 60(12+10) = 1320. Speed should be truncated, so a car moving 4.341 will be calculated at 4mph.

program should accept these inputs:

Time at Checkpoint A (in minutes)
Time at Checkpoint B (in minutes)
Speed limit in time zone

currently all i really have is the basic in and out commands, and i believe the formula for the checkpoints. can anyone with some time please look over my program and help me get started in the right direction? I cant seem to get the if else if statement to work.

for example if input the following
CheckpointA: 1230
CheckpointB: 1237
Speed Limit: 55

it should report that no ticket is issued... however my program continues to give a ticket

Code:
```
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()

{
double base = 150, fee = 5, ticket;
int mph, timeA, timeB;

cout << "Enter license plate number" << endl;

cout << "Enter time at Checkpoint A" << endl;

cin >> timeA;

cout << "Enter time at Checkpoint B" << endl;

cin >> timeB;

cout << "Enter speed limit in the zone" << endl;

cin >> mph;

if(mph < (timeB - timeA)*12)
{
ticket = base + fee * ((timeB-timeA)*12- mph);
cout << "A ticket of \$" << ticket << " is issued to " << license << endl;
}
else
cout << "No ticket issued" << endl;

return 0;
}```

2. it should report that no ticket is issued... however my program continues to give a ticket
Check your assumptions. Simple math: If you travel 5 miles in 7 minutes, how fast are you going?

3. And proof why I should have at least two cups of coffee before attempting basic math! What a dumbass I am. Sorry. I reversed it to 7 miles in 5 minutes.

5 miles/7 minutes = x miles/60 minutes
7x = 300
x = 42.86 mph

So you need to fix your math is all.

4. ^
thanks for the pointers
now i think i got the math portion figured out... but now im having trouble with the ticket being calculated properly.. this what i have as of right now..

the price of the ticket comes out incorrectly.. as well as reporting that tickets arent issued when they should be... im almost sure that my if statement is not set correctly

Code:
```#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()

{
double base = 150, fee = 5, ticket;
int mph, timeA, timeB, Speed = 0, Time_Taken = 0,diffSpeed = 0;

cout << "Enter license plate number" << endl;

cout << "Enter time at Checkpoint A" << endl;

cin >> timeA;

cout << "Enter time at Checkpoint B" << endl;

cin >> timeB;

cout << "Enter speed limit in the zone" << endl;

cin >> mph;

Time_Taken = timeB - timeA;
Speed = (5 / Time_Taken ) *60 + 0.5;

diffSpeed = mph - Speed;

if ( diffSpeed > mph )
{
ticket = base + fee * diffSpeed;

cout << "A ticket of \$" << ticket << " is issued to " << license << endl;
}
else
cout << "No ticket issued" << endl;

return 0;

}```

5. 5 divided by 7 gives you zero, with a remainder of 5 which is ignored.
Either do the multiplication first so that it's five times sixty, divided by seven, or make sure one of the operands is a floating point type.