subject

The HiRisq Insurance company determines auto insurance rates based on a driver’s age, number of tickets in the last three years, and the value of the car. Write a program that reads the user input for i) age, ii) the number of traffic tickets received in the last three years, and iii) the value of the car. Once those three values have been read in, your program will calculate and print the monthly premium that this driver must pay to be insured.

Use the following rules: The base premium is 5 percent of the value of the car. Drivers under 25 years old pay 15 percent more and drivers from 25 through 29 pay 10 percent more. A driver with one ticket pays 10 percent over the premium already figured. Two tickets draws a 25 percent extra charge; three tickets adds 50 percent; and drivers with more than three tickets are refused.

You must be able to calculate the premium for a given driver using pencil, paper and calculator (without using the computer) before you will be able to start writing the Java program to calculate the premium. It is a good idea to use your own information (age, traffic tickets and value of car) to practice calculating a premium without the computer.

Notes:

• To calculate the premium, first apply the base rate of 5% of the value of the car to get the base premium. Then add a percentage of that premium based on the age of the driver. Finally add a percentage of that premium for the number of tickets. For example, for the driver age 19:

Premium = (850 * .05)* 1.15 * 1.50 = 73.3125
^ ^ ^
car value age tickets
• Structure the branches so that you have NO code duplication.

In order to receive full credit:

• Test your program thoroughly, to make sure that it generates the correct premium for many different ages, numbers of tickets, and values of car. Use your own information to start.

• Have no repeated code in your program.

• Your code must not test for conditions that are certain to be true.

• Follow all program guidelines, including a comment at the top of the program that tells what it does. You can find the Program Guidelines in Canvas Module "Week 2."
Here is my code and I keep getting the wrong answer or keep getting really big answers.
import java. util. Scanner;

public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);

int age = scnr. nextInt();
int tickets = scnr. nextInt();
int carValue = scnr. nextInt();

System. out. println("Your age is: " + age);
System. out. println("Number of tickets is: " + tickets);
System. out. println("Your Car Value is: " + carValue);

double premium;
premium = (carValue * 0.05) * age * tickets;

if (age < 25) {
premium = premium + (premium * 0.15);
}
else if (age > 24) {
premium = premium + (premium * 0.10);
}

if (tickets == 1) {
premium = premium + (premium * 0.10);
}
else if (tickets == 2) {
premium = premium + (premium * 0.25);
}
else if (tickets == 3) {
premium = premium + (premium * 0.50);
}
else if (tickets > 3) {
premium = 0;
}

System. out. println("$" + premium);
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:20
The north and south regions had very diferent economies in the 1800s.
Answers: 1
question
Computers and Technology, 23.06.2019 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
What is the name of the sound effect that danny hears
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data.
Answers: 1
You know the right answer?
The HiRisq Insurance company determines auto insurance rates based on a driver’s age, number of tick...
Questions
question
Chemistry, 02.09.2021 06:30
question
Mathematics, 02.09.2021 06:30
question
Mathematics, 02.09.2021 06:30
question
Mathematics, 02.09.2021 06:40
question
Chemistry, 02.09.2021 06:40
question
Biology, 02.09.2021 06:40
Questions on the website: 13722361