63 160
Assignments Done
99,3%
Successfully Done
In July 2018

# Answer to Question #54853 in C++ for Princess Medroso

Question #54853
Kindly help me, I need a FOR loop code for this problem. Thank you
Your city’s Parking Violation Bureau wants you to write a program to compute
fines for parking violations.There are four types of violation:type A carries a fine
of 10 USD,type B carries a fine of 20 USD,type C carries a fine of USD30,and type D carries
a fine of 50 USD.The program should ask for the number of type A violations, thenumber of type B violations,and so on.If the number of type A,B,or C violations
exceeds 10,impose an additional fine of 50 USD 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 indi-
vidually exceeds 10,impose an additional fine of 75 USD.If the number of type D vi-
olations exceeds three,impose an additional fine of 20 USD 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.
#include <iostream>

using namespace std;

int main() {

int numberAViolations, numberBViolations, numberCViolations, numberDViolations;
int totalFine;
int userChoice;

do {

totalFine = 0;

do {

cout<<"Enter number of type A violations: ";
cin>>numberAViolations;

if (numberAViolations < 0)
cout<<"Wrong input\n";

} while(numberAViolations < 0);

do {

cout<<"Enter number of type B violations: ";
cin>>numberBViolations;

if (numberBViolations < 0)
cout<<"Wrong input\n";

} while(numberBViolations < 0);

do {

cout<<"Enter number of type C violations: ";
cin>>numberCViolations;

if (numberCViolations < 0)
cout<<"Wrong input\n";

} while(numberCViolations < 0);

do {

cout<<"Enter number of type D violations: ";
cin>>numberDViolations;

if (numberDViolations < 0)
cout<<"Wrong input\n";

} while(numberDViolations < 0);

totalFine += numberAViolations * 10;
totalFine += numberBViolations * 20;
totalFine += numberCViolations * 30;
totalFine += numberDViolations * 50;

if (numberAViolations > 10 || numberBViolations > 10 || numberCViolations > 10) {

if (numberAViolations > 10)
totalFine += 50;
if (numberBViolations > 10)
totalFine += 50;
if (numberCViolations > 10)
totalFine += 50;

}
else
if (numberAViolations + numberBViolations + numberCViolations > 20)
totalFine += 20;

if (numberDViolations > 3) {
numberDViolations -= 3;
totalFine += numberDViolations * 20;
}

cout<<"The Total fine for the current person: \$"<<totalFine<<endl<<endl;

cout<<"You want calculate total fine for another person?\n";
cout<<"1. Yes\n";
cout<<"2. No\n";

do {

cin>>userChoice;

if (userChoice != 1 && userChoice != 2)
cout<<"Wrong input\n";

}while (userChoice != 1 && userChoice != 2);

} while(userChoice != 2);

cin.clear();
cin.ignore(1000, '\n');

cout<<"Press any key to continue . . .\n";
cin.get();

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!