1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
BartSMP [9]
3 years ago
5

The Harrison Group Life Insurance company computes annual policy premiums based on the age the customer turns in the current cal

endar year. The premium is computed by taking the decade of the customre's age, adding 15 to it, and multiplying by 20. For example, a 34-year-old would pay $360, which is calculated by adding the decades (3) to 15, and then multiplying by 20. Write an application that prompts a user for the current year and then display the returned amount. Save the application as Insurance,java.
Computers and Technology
1 answer:
Ksenya-84 [330]3 years ago
8 0

Answer:

The JAVA program for the scenario is given below.

import java.util.Scanner;

import java.lang.*;

public class Insurance

{

   //static variables to hold mandatory values

   static int age;

   static int premium;

   static int decades;

public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       //user prompted to enter present age

 System.out.print("Enter your age in current year: ");

 age = sc.nextInt();

 //computation to calculate premium amount

 decades = age/10;

 premium = (decades + 15)*20;

 System.out.println("");

 System.out.println("The annual premium to be paid for age "+age+" is $"+ premium);

}

}

OUTPUT

Enter your age in current year: 45

The annual premium to be paid for age 45 is $380

Explanation:

1. The variables are declared with integer datatype to hold customer age, decades and premium.  

2. All the variables are declared static so that they can be accessible inside main() which is a static method.

3. Inside main(), object of Scanner is created, sc.

4. User is asked to enter present age.

5. User input is taken into age using scanner object, sc and nextInt() method.

6. Following this, the decades in customer’s age is computed by dividing age by 10 and assigned to decades variable.

7. Next, annual premium is calculated by adding 15 to decades and then, multiplying the result by 20. The final result is assigned to premium variable.

8. A new line is inserted before printing the annual premium amount.

9. The calculated annual premium amount based on customer’s present age is displayed.

10. The class having main() method is named Insurance. Hence, the program is named as Insurance.java.

11. Only one class is taken in the program since nothing is specifically mentioned about classes in the question.

12. The Insurance class is declared public since execution begins with main() method.

13. If more than one class is present in the Java program, only the class having main() method is declared public; other classes are not declared public.

You might be interested in
Kiera is building a new computer and wants to make sure she has an adequate power supply for all the new equipment she is purcha
VikaD [51]
700w power supply is very adequate
7 0
3 years ago
Read 2 more answers
When you save a presentation with a .potx file extension, which type of powerpoint file is created?
Elena L [17]
A file with the POTX file extension is a Microsoft PowerPoint Open XML Template file used to maintain the same layout, text, styles, and formatting across multiple PPTX files.
6 0
2 years ago
Predict how digital video will be viewed in the future. Step into the year 2028. How are people viewing digital video? Or have w
Nostrana [21]
<span>Google Glass was interesting; a personal screen overlaid onto the real world, with 'augmented reality' ideas. The Nintendo 3DS was the first 'no glasses' portable 3D system.

So I predict Google 3D Glasses with built in Dolby 9.1 sound emulation. </span>
4 0
3 years ago
Read 2 more answers
In which step of writing a program does a programmer first use a<br> compiler?<br> documentin
Allisa [31]

A compiler is often used when you want to test your code; that would often be your second step.

6 0
2 years ago
Help Asap! Marking brainliest!✨
gulaghasi [49]

Answer:

The answer would be After the slide you are viewing.

I hope this helped!

8 0
2 years ago
Read 2 more answers
Other questions:
  • I want to work on cloud computing and i need some help on how to start ?
    6·1 answer
  • A client accessing a network share folder has authenticated into the system and has full access rights to a folder share. But af
    11·1 answer
  • An Einstein Analytics team wants to create a dashboard that displays values from an external, on-premise Oracle Database. What a
    7·1 answer
  • If nothings faster than light then how do the dark get there first????
    5·2 answers
  • In a gear system, when you gain torque you lose what?
    11·1 answer
  • Thomas has signed a deal with a production house that allows them to use his images on their website. What is required when imag
    5·2 answers
  • A _________ is a component commonly used in an analog pressure gauge. Use letter keys to select choices A microprocessor B press
    8·1 answer
  • JAVA
    12·1 answer
  • I’ll mark brainliest, thanks
    10·2 answers
  • 11:25
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!