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
Pani-rosa [81]
3 years ago
7

Create an application for a library and name it FineForOverdueBooks. TheMain() method asks the user to input the number of books

checked out and the number of days they are overdue. Pass those values to a method named DisplayFine that displays the library fine, which is 10 cents per book per day for the first seven days a book is overdue, then 20 cents per book per day for each additional day.
The library fine should be displayed in the following format:

The fine for 2 book(s) for 3 day(s) is $0.60

(The numbers will vary based on the input.)
Computers and Technology
1 answer:
andrew11 [14]3 years ago
4 0

Answer:

//The Scanner class is imported which allow the program to receive user input

import java.util.Scanner;

//Class Solution is defined to hold problem solution

public class Solution {

   // The main method which signify the begining of program execution

   public static void main(String args[]) {

       // Scanner object 'scan' is defined to receive input from user keyboard

       Scanner scan = new Scanner(System.in);

       // A prompt is display asking the user to enter number of books

       System.out.println("Please enter number of books: ");

       // the user response is assigned to numberOfBook

       int numberOfBook = scan.nextInt();

       // A prompt is displayed asking the user to enter the number of days over due

       System.out.println("Please enter number of days over due: ");

       // the user response is assigned to numberOfDaysOverDue

       int numberOfDaysOverDue = scan.nextInt();

       //displayFine method is called with numberOfBook and numberOfDaysOverDue as arguments

       displayFine(numberOfBook, numberOfDaysOverDue);

   

   }

   

   //displayFine method is declared having two parameters

   public static void displayFine(int bookNumber, int daysOverDue){

       // fine for first seven days is 10cent which is converted to $0.10

       double firstSevenDay = 0.10;

       // fine for more than seven days is 20cent which is converted to $0.20

       double moreThanSevenDay = 0.20;

       // the fine to be paid is declared

       double fine = 0;

       // fine is calculated in the following block

       if(daysOverDue <= 7){

           //the fine if the over due days is less than or equal 7

           fine = bookNumber * daysOverDue * firstSevenDay;

       } else{

           // the extra days on top of the first seven days is calculated and assigned to extraDays

           int extraDays = daysOverDue - 7;

           //fine for first seven days is calculated

           double fineFirstSevenDays = bookNumber * 7 * firstSevenDay;

           // fine for the extradays is calculated

           double fineMoreThanSevenDays = bookNumber * extraDays * moreThanSevenDay;

           // the total fine is calculated by adding fine for first seven days and the extra days

           fine = fineFirstSevenDays + fineMoreThanSevenDays;

       }

       // The total fine is displayed to the user in a nice format.

       System.out.printf("The fine for " + bookNumber + " book(s) for " + daysOverDue + " day(s) is: $%.02f", fine);

   }

}

Explanation:

The program first import Scanner class to allow the program receive user input. Then the class Solution was defined and the main method was declared. In the main method, user is asked for number of books and days over due which are assigned to numberOfBook and numberOfDaysOverDue. The two variable are passed as arguments to the displayFine method.

Next, the displayFine method was defined and the fine for the first seven days is calculated first if the due days is less than or equal seven. Else, the fine is calculated for the first seven days and then the extra days.

The fine is finally displayed to the user.

You might be interested in
Portrait and Landscape are
ValentinkaMS [17]

Answer:

a page layout

Explanation:

6 0
3 years ago
Heads or tails
Pani-rosa [81]

import random

heads = 0

tails = 0

i = 0

while i < 1000:

   rnd_value = random.randint(1, 2)

   if rnd_value == 1:

       heads += 1

       print("heads")

   else:

       tails += 1

       print("tails")

   i += 1

print("Heads appeared {} times and tails appeared {} times".format(heads, tails))

I hope this helps!

5 0
3 years ago
Describe at least three virus scanning techniques
Natasha_Volkova [10]

Answer:

 Virus scanning technique is the process to scan the software and identify the various viruses in the computing device. The basic aim of virus scanning technique is to provide the information security and review virus in the given program.

The three virus scanning techniques are as follow:

Behavior detection: This type of detection observe the execution of the program and helps in modifying the host file in the system.

Signature based detection: This type of detection uses various type of key aspects for examine the file for creating the fingerprint. It basically represent the byte stream in the file.

Heuristics detection: The basic aim is to detect or examine the files and it is basically designed to improve the security system. It is also known as heur.

4 0
3 years ago
What is the purpose of social networking sites
ipn [44]

Explanation:

social networking sites allow users to share ideas, digital photos and videos, posts, and to inform others about online or real world activities and events with people in their network.

6 0
3 years ago
Match the parts of the website address with its correct explanation. http://www.usa.gov/Agencies/federal.shtm/​
meriva

sorry I was just testing something

6 0
3 years ago
Read 2 more answers
Other questions:
  • Brenda is a college student who enjoys downloading music, movies, and television shows from the Internet. She also uses the Inte
    7·1 answer
  • Write a program to read as many test scores as the user wants from the keyboard (assuming at most 50 scores). Print the scores i
    13·1 answer
  • To join two or more objects to make a larger whole is to _____________ them.
    11·2 answers
  • Which statement correctly describes how the density and temperature of air is related .
    7·1 answer
  • When does the VB.NET programming environment start to operate?
    10·1 answer
  • Can you give me a long list of anime
    6·2 answers
  • The labels on the tab buttons on the Driver tab of the Windows Device are Driver Details, Update Driver, Roll Back Driver, Unins
    12·1 answer
  • What is the best way to get the most out of the box?
    14·2 answers
  • 10. Question<br> What are the drawbacks of purchasing something online? Check all that apply.
    5·1 answer
  • Whats the overall mood of the song Rags2Riches by rod wave
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!