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 the internet?
aliya0001 [1]
What you're currently on. or a global computer network providing a variety of information and communication facilities, consisting of interconnected networks using standardized communication protocols.
7 0
3 years ago
Read 2 more answers
When the tv was created (year)
nikitadnepr [17]

Answer:

1927

Explanation:

6 0
3 years ago
Read 2 more answers
In order to identify the transmissions that belong to each VLAN, a switch will add a tag to Ethernet frames that identifies the
ira [324]

Answer:

True

Explanation:

Frame Tagging is a method Cisco developed to identify packets travelling through links also called VLAN Tagging.

8 0
3 years ago
"which term is used to describe the process of encasing one protocol or packet inside another protocol or packet
svlad2 [7]
<span>tunneling Term used 
process of encasing one protocol or packet inside another protocol or packet</span>
7 0
3 years ago
Can I get money for the cars which I sell in my showroom mod in gta v(5)
nikitadnepr [17]

Answer:

Yes you can

Explanation:

5 0
2 years ago
Other questions:
  • In 3–5 sentences, describe the unique challenges e-mail presents for business communications.
    13·2 answers
  • The PATH environment variable.
    5·1 answer
  • Which name is given to an architectural framework for delivering ip multimedia services?
    8·1 answer
  • All systems have ___________.
    9·2 answers
  • Whats yall favv scary movie
    11·1 answer
  • Create a PHP page that contains an array of at least 20 movie titles or book titles (your choice). The HTML page should have an
    7·1 answer
  • Calculate the total and average number from 1 to 100<br>​
    12·1 answer
  • Describe how you will lunch a web browser using the start menu​
    6·2 answers
  • When you execute this block in Scratch, your computer is actually doing several things: retrieving values from memory representi
    9·1 answer
  • File names should be limited to 144 characters.<br><br> true or false
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!