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.
1
Expert's answer
2015-09-22T11:10:21-0400
#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;
Comments
Leave a comment