Java Programming
Java Programming
9th Edition
ISBN: 9780357616635
Author: Joyce Farrell
Publisher: CENGAGE L
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 3, Problem 9PE

Explanation of Solution

Program code:

Insurance.java

//import the packages

import java.util.*;

//define the class Insurance

public class Insurance

{

//define the main() main

public static void main(String args[])

{

//Creating Scanner instance to scan console for User input

Scanner console = new Scanner(System.in);

//prompt the user to enter the current year

System.out.println("please enter the current year: ");

//scan for the user input

int currentyear = console.nextInt();

//prompt the user to enter the birth year

System.out.println("please enter ur birth year : ");

//scan for the input

int birthyear= console.nextInt();

//method calling by paasing values

int premium=premiumAmount(currentyear,birthyear);

//print the value of premium

System.out.println("total premium amount :\t$"+premium);

}

//define the method premiumAmount()

public static int premiumAmount(int cy,int by)

{

//declare an integer variable

int age=cy-by;

//print the age

System.out.println("Age is : "+age);

//divide the age by 10 and save to d

int d=(age)/10;

//print the value of d

System.out.println("decade is : "+d);

//add 15 to d and save to add

int add=d+15;

//return the value

return(add*20);

}

}

Explanation:

The above snippet of code is used create a class “insurance” to declare the static methods to calculate the premium...

Blurred answer
Students have asked these similar questions
Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average. An example of the program is shown below: Enter a score >> 6 Enter another score or 99 to quit >> 7 Enter another score or 99 to quit >> 9 Enter another score or 99 to quit >> 7 Enter another score or 99 to quit >> 99 4 valid scores were entered Highest was 9 Lowest was 6 Average was 7.25     PLEASE WRITE A JAVA CODE   import java.util.*; public class QuizScoreStatistics {     public static void main (String args[]) {         // Write your code here     } }
Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.
This is the question: Write an application that displays every perfect number from 1 through 1,000. A perfect number is one that equals the sum of all the numbers that divide evenly into it. For example, 6 is perfect because 1, 2, and 3 divide evenly into it, and their sum is 6; however, 12 is not a perfect number because 1, 2, 3, 4, and 6 divide evenly into it, and their sum is greater than 12. This is the code given:   public class Perfect {     public static void main (String args[]) {         // Write your code here     }     public static boolean perfect(int n) {         // Write your code here     } }
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY