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 09:00
What is one way in which tablets differ from laptops and notebooks? tablets are designed for touch-based interaction. tablets are designed to be used as desktops. tablets are designed for input via a keyboard and mouse. tablets are designed to be larger than laptops.
Answers: 1
question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
Avariable definition defines the name of a variable that will be used in a program, as well as
Answers: 3
question
Computers and Technology, 23.06.2019 03:30
Ihave a singular monitor that is a tv for my computer. recently, i took apart my computer and put it back together. when i put in the hdmi cord and booted the computer to see if it worked, the computer turned on fine but the screen was blue with "hdmi no signal." i've tried everything that doesn't require buying spare parts, any answer is appreciated!
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
Mathematics, 02.02.2020 20:51
question
Health, 02.02.2020 20:51
Questions on the website: 13722367