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
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.…
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     } }
Reza Enterprises sells tickets for buses, tours, and other travel services. Because Reza frequently mistypes long ticket numbers, Reza Enterprises has asked his students to write an application that shows if a ticket is invalid. Your application/program tellsthe ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you lose the last digit of the number, then divide by 7, the remainder of the division is exactly the same to the last dropped digit. This process is shown below:   Step 1: Enter the ticket number; for example 123454   Step 2: Remove the last digit, leaving 12345   Step 3: Determine the remainder when the ticket number from step 2 is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4.   Step 4: Display a message to the ticket agent indicating whether the ticket number is valid or not..     Test your application with the following ticket numbers:   - 123454; is a valid ticket number - 147103; is a valid ticket number -…
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