Computers and Technology

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);
}
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:30, brin1021
Jessie has received a contract to build a real-time application for a baker. however, the baker doesn't want to invest too much money. his only requirement is that he wants the customers to know which cupcakes are available at what time and in what quantity. so his core requirement is that the details of product should be in real time. what platform can jessie use to develop this application?
Answers: 1
image
Computers and Technology, 22.06.2019 11:00, loveworld3798
When working with a team you should always do the following, except? question 3 options: be dependable and trustworthy be sensitive to others feelings do your fair share critique members of the group
Answers: 2
image
Computers and Technology, 23.06.2019 16:00, ginaaa20
Which analyst position analyzes information using mathematical models to business managers make decisions?
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, amayax77
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
Do you know the correct answer?
The HiRisq Insurance company determines auto insurance rates based on a driver’s age, number of tick...

Questions in other subjects:

Konu
Mathematics, 16.12.2020 21:10