EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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.
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     } }
The game of Nim starts with a random number of stones between 15 and 30. Two players alternate turns and on each turn may take either 1, 2, or 3 stones from the pile. The player forced to take the last stone loses. Create a nim application in python that allows the user to play against the computer. In this version of the game, the application generates the number of stones to begin with, the number of stones the computer takes, and the user goes first. The Nim application code should:  prevent the user and the computer from taking an illegal number of stones. For example, neither should be allowed to take three stones when there are only 1 or 2 left. include an is_valid_entry() function to check user input. include a draw_stones() function that generates a random number from 1 to 3 for the number of stones the computer draws.   include separate functions to handle the user’s turn and the computer’s turn. My problem is that the code is not outputting like it's supposed to.…
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