Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Styles Airport parking violation bureau wants you to Design a program to compute

ID: 3873613 • Letter: S

Question

Styles Airport parking violation bureau wants you to Design a program to compute fines for parking violations. There are four types of violation: type A carries a fine of $10, type B carries a fine of $20, type C carries a fine of $30, and type D carries a fine of $50. The program should ask for the number of type A violations, the number of type B violations, and so on. If the number of type A, B, or C violations exceeds 10, impose an additional fine $50 for each category that exceeds 10. If the total number of type A, B, or C exceeds 20 but none of types A, B, or C individually exceeds 10, impose an additional fine of $75. If the number of type D violations exceeds 3, impose an additional fine of $20 for each type D violation over three. The program should print the total fine for the person.

Explanation / Answer

Code is:

#include <bits/stdc++.h>
using namespace std;

int main(){
int na,nb,nc,nd;
cout<<"No. of violations of type A, B, C and D: ";
cin>>na>>nb>>nc>>nd;
int fa,fb,fc,fd;
fa=10;fb=20;fc=30;fd=50;
long total=fa*na+fb*nb+fc*nc+fd*nd;
if(na>10) total+=50;
if(nb>10) total+=50;
if(nc>10) total+=50;
if(na<10 && nb<10 && nc<10 && na+nb+nc>20) total+=75;
if(nd>3) total+=(nd-3)*20;
cout<<"Total fine for the person is : "<<total<<endl;
return 0;
}

Output is:

No. of violations of type A, B, C and D: 10 2 20 5
Total fine for the person is : 1080