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
What is one difference between a web page and a web application?
saul85 [17]

Answer:

A website is a group of globally accessible, interlinked web pages which have a single domain name. A web application is a software or program which is accessible using any web browser. Developing your website helps you in branding your business.

8 0
2 years ago
Me podrian ayudar con esta pregunta...
tamaranim1 [39]
The answer is B , Hope this helps , I don’t speak Spanish but a little bit I understand , I’m sure that’s the correct answer answer
8 0
3 years ago
Read 2 more answers
Jack needs to improve sales on a local service for the elderly. What would be the best place for him to place an ad?
Lorico [155]

Answer: D

Local news channels

Explanation:

Since Jack is trying to improve local service the local news would be the best fit to reach the maximum amount of people in his area.

3 0
3 years ago
Read 2 more answers
Which instrument is NOT an example of a chordophone?
Colt1911 [192]

Answer:

b. xylophone

Explanation:

7 0
3 years ago
Using MRTG, Ntop, and SNMPC to collect flow data from your routers and switches to identify traffic/packet anomalies is an examp
laiz [17]

Is an example of reactive, signature based IDS/IPS

Reactive, signature based IDPS technology is one of the many methodologies used to detect attacks. In a signature based IDS, a misuse detection identifies intrusions by watching for patterns of traffic and compare them against observed events or a database of signatures from known threats. Reactive IDS/IPS, on the other hand, will not only detect and alert malicious traffic but also take pre-defined proactive actions. Using MRTG, Ntop, and SNMPC in routers will monitor traffic and help network managers easily see issues like DOS attacks and security problems.


3 0
3 years ago
Read 2 more answers
Other questions:
  • To calculate the multiple of 5
    9·1 answer
  • Points!!!!!!!! pls help
    13·2 answers
  • Briefly summarize two examples of cybercrime stories.<br> quick pleaseeee
    10·1 answer
  • What is the term for the error caused when one end of an unshielded twisted-pair (UTP) cable is terminated in the T568A configur
    6·1 answer
  • A user is having trouble signing in to the domain from a computer that has been out of service for several months, and nobody el
    7·1 answer
  • What do you mean by real time system? Why real time system needs to response within limited time?
    6·1 answer
  • Custom actions help your users by
    6·1 answer
  • Which option should you choose to change the background of your current slide?
    10·2 answers
  • How does social network use message to entertain?
    14·1 answer
  • What symbol should you look for to determine who owns the intellectual property of a website? the logo the web address the domai
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!