Question #15973

Your city's Parking Violations Bureau wants you to write a program for computer fines for parking violations. There are four types of violations: type A car carries a fine of $10,type B carries a find 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,B or C 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$50 fine for each category that exceeds 10. If the total number of type A,B or individually exceeds 10, impose and 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 display the total fine for the person. The program should process any number of persons.

Expert's answer

#include "stdafx.h"

#include <iostream>

#include

<iomanip>

using namespace std;

int main()

{

const double

TYPEA = 10, TYPEB = 20, TYPEC = 30, TYPED = 50;

double result1, result2,

Total,typeA, typeB, typeC, typeD, finA, finB, finC;

finC=0;

cout <<

setprecision(2)

<< setiosflags(ios::fixed)

<<

setiosflags(ios::showpoint);

// Obtain Input

result1=0;

cout

<< "Enter total number of A violations: ";

cin >> typeA;

if

(typeA >= 10)

finA = (typeA * TYPEA + 50);

else

finA = (typeA *

TYPEA);

cout << "Enter total number of B violations: ";

cin

>> typeB;

if (typeB >= 10)

finB = (typeB * TYPEB +

50);

else

finB = (typeB * TYPEB);

cout << "Enter total number

of C violations: ";

cin >> typeC;

if (typeC >= 10)

finC =

(typeC * TYPEC + 50);

else

finA = (typeC * TYPEC);

result1 = (finA

+ finB + finC);

if (result1 >= 20)

(result1 + 75);

cout

<< "Enter total number of D violations: ";

cin >>

typeD;

result2=0;

if (typeD >= 3)

(typeD * TYPED +

20);

else{

result2 = (typeD + TYPED);

}

//Display

results

cout << endl << endl;

cout << "The total

fine for A, B, and C violations is " << result1 << endl;

cout

<< "The total fine for D violations is " << result2 <<

endl;

Total = (result1 + result2);

cout << "The total of all

violations:" << Total << endl;

system

("PAUSE");

return 0;

}

#include <iostream>

#include

<iomanip>

using namespace std;

int main()

{

const double

TYPEA = 10, TYPEB = 20, TYPEC = 30, TYPED = 50;

double result1, result2,

Total,typeA, typeB, typeC, typeD, finA, finB, finC;

finC=0;

cout <<

setprecision(2)

<< setiosflags(ios::fixed)

<<

setiosflags(ios::showpoint);

// Obtain Input

result1=0;

cout

<< "Enter total number of A violations: ";

cin >> typeA;

if

(typeA >= 10)

finA = (typeA * TYPEA + 50);

else

finA = (typeA *

TYPEA);

cout << "Enter total number of B violations: ";

cin

>> typeB;

if (typeB >= 10)

finB = (typeB * TYPEB +

50);

else

finB = (typeB * TYPEB);

cout << "Enter total number

of C violations: ";

cin >> typeC;

if (typeC >= 10)

finC =

(typeC * TYPEC + 50);

else

finA = (typeC * TYPEC);

result1 = (finA

+ finB + finC);

if (result1 >= 20)

(result1 + 75);

cout

<< "Enter total number of D violations: ";

cin >>

typeD;

result2=0;

if (typeD >= 3)

(typeD * TYPED +

20);

else{

result2 = (typeD + TYPED);

}

//Display

results

cout << endl << endl;

cout << "The total

fine for A, B, and C violations is " << result1 << endl;

cout

<< "The total fine for D violations is " << result2 <<

endl;

Total = (result1 + result2);

cout << "The total of all

violations:" << Total << endl;

system

("PAUSE");

return 0;

}

Learn more about our help with Assignments: C++

## Comments

## Leave a comment