Part A and B please The speeding ticket fine policy in Potyo
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
*/

