Answer to Question #16719 in C++ for Theodore Michael

Question #16719
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 of $10, type B carries a fine of $20, type C carries a fine of $30, and a type D carries a fine of $50. The program should ask for the name of offender, the number of type A violations, the number of type B violations, and so on. Store the offenders name in a string object. The program should display the offenders name and the total fine for the person.
1
Expert's answer
2012-10-17T10:26:36-0400
import java.util.Scanner;

public class Store {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

String name;

int violationA = 0, violationB = 0, violationC = 0, violationD = 0, total = 0;



System.out.println("Enter the offenders name: ");

name = in.nextLine();

System.out.println("Validations A count: ");

String tempQuantity = in.nextLine();

violationA += Integer.parseInt(tempQuantity) * 10;

total += violationA;

System.out.println("Validations B count: ");

tempQuantity = in.nextLine();

violationB += Integer.parseInt(tempQuantity) * 20;

total += violationB;

System.out.println("Validations C count: ");

tempQuantity = in.nextLine();

violationC += Integer.parseInt(tempQuantity) * 30;

total += violationC;

System.out.println("Validations D count: ");

tempQuantity = in.nextLine();

violationD += Integer.parseInt(tempQuantity) * 50;

total += violationD;




System.out.println("Total fine of " + name + " : $" + total);




}

}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS