Part A and B please The speeding ticket fine policy in Potyo

Part A and B please.
The speeding ticket fine policy in Potyomkin village is $60.00 plus $5.00 for each mph over the speed limit. Moreover, the fine is doubled for any speed limit violation in a construction zone. furthermore, a penalty of $250.00 is added for any speed over 90 mph. Write a function, called speeding(), that takes three formal parameters a speed lime (int), clocked speed (int) and whether the speed limit violation took place in a construction zone or not (\' Y or \'n\') as input, and either returns zero indicating the speed was legal or returns the amount of the fine, if the speed is illegal. The caller of the function speeding() in the test() function then prints a message using the format shown in the next problem. You must use If statements in your solution. Your speeding() function must not print anything. Do not import external module In your solution. Write a test function, called test(), to test the speeding() function with the following actual parameters and write a message accordingly: Call test() in your program and show the result. Examples of the correct output format include: Speeding violation fine for speed 35 is 50 mph zone(contruction = \'Y\'): $0.00 Speeding violation fine for speed 95 is 80 mph zone(contruction = \'n\'): $ 385.00

Solution

// C++ code ticket fine

#include <iostream>
#include <string.h>
#include <fstream>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <stdlib.h>
#include <vector>

using namespace std;

double speeding(int limit,int clockedSpeed,char zone)
{
double fine= 0.0;

if(clockedSpeed > limit)
fine = (clockedSpeed-limit)*5 + 60;
else
fine = 0;

if(zone == \'y\')
fine = fine*2;

if(clockedSpeed > 90.0)
fine = fine + 250;

return fine;
}

int main ()
{
double fine;

fine = speeding(45,35,\'y\');
cout << \"Speeding violation fine for speed \" << 35 << \" in \" << 45 << \" mph zone (construction = \'y\') $\" << fine << endl;

fine = speeding(45,55,\'y\');
cout << \"Speeding violation fine for speed \" << 55 << \" in \" << 45 << \" mph zone (construction = \'y\') $\" << fine << endl;

fine = speeding(45,55,\'n\');
cout << \"Speeding violation fine for speed \" << 55 << \" in \" << 45 << \" mph zone (construction = \'n\') $\" << fine << endl;

fine = speeding(45,95,\'y\');
cout << \"Speeding violation fine for speed \" << 95 << \" in \" << 45 << \" mph zone (construction = \'y\') $\" << fine << endl;

fine = speeding(45,95,\'n\');
cout << \"Speeding violation fine for speed \" << 95 << \" in \" << 45 << \" mph zone (construction = \'n\') $\" << fine << endl;

return 0;
}

/*
output:

Speeding violation fine for speed 35 in 45 mph zone (construction = \'y\') $0
Speeding violation fine for speed 55 in 45 mph zone (construction = \'y\') $220
Speeding violation fine for speed 55 in 45 mph zone (construction = \'n\') $110
Speeding violation fine for speed 95 in 45 mph zone (construction = \'y\') $870
Speeding violation fine for speed 95 in 45 mph zone (construction = \'n\') $560

*/

Part A and B please. The speeding ticket fine policy in Potyomkin village is $60.00 plus $5.00 for each mph over the speed limit. Moreover, the fine is doubled
Part A and B please. The speeding ticket fine policy in Potyomkin village is $60.00 plus $5.00 for each mph over the speed limit. Moreover, the fine is doubled

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site