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
Which type of attack modifies the fields that contain the different characteristics of the data that is being transmitted?
tatuchka [14]

Answer:

An HTTP Header attack

Explanation:

In web applications an HTTP refers to Hypertext Transfer Protocol and an HTTP Header is the value that is displayed in  a request or response message, the header has a name and a value separated by a colon.

An HTTP header attack called an header injection is a vulnerability that is present when users' inputs are required for the dynamic generation of HTTP headers. This vulneraility allows several security threats to be carried out, some examples are:

  1. Malicious site redirection
  2. Cross-site scripting, and
  3. Session fixation through the set-cookie header
8 0
2 years ago
The CSS property of top , bottom , left , or right moves the element the specified distance from the respective edge of the clos
borishaifa [10]

Answer:

Relative

Explanation:

Web development is a process of designing and building a web page or website. HTML, CSS and JavaScript are the basic tools used in building a website.

Cascading style sheet or CSS is a web development tool used to style the content of a HTML file. Css has pointers used to represent HTML elements for styling. A HTML element can be fixed, absolute or relative.

When a CSS file sets an element relative to it container or other element, the element can be moved to the right, left, top or bottom position relative to the four corners of the parent element.

7 0
3 years ago
Is a defense of a political position an argument
shutvik [7]

Answer:

yes

Explanation:

yyyyyyyyyyeeeeeeeeesssssss

8 0
2 years ago
If a user wished to insert a triangle or a callout figure in a document, he or she should select the _____ option.
Vlada [557]
The Insert Tab option

You can add a shape your word, excel or PowerPoint document to make a drawing. To do this in MS Word, click on the Insert tab, and in the illustration group, click on the shapes option. Click the shapes or callouts that you would like to insert and then drag to place the shape anywhere in the document.






4 0
2 years ago
What lets you do many things, like write book reports and stories?
Marina CMI [18]
A -
Application programs
8 0
2 years ago
Read 2 more answers
Other questions:
  • Cleo finds herself frequently searching for messages from particular senders or with specific subjects. What should she create
    5·1 answer
  • What operator is used to create a validation rule? A. – B. / C. &lt; or &gt; D. +
    12·1 answer
  • reate a class called Plane, to implement the functionality of the Airline Reservation System. Write an application that uses the
    5·1 answer
  • What software is typically used for larger systems?
    11·1 answer
  • What is the name of the program file that you can enter in the Windows search or Run box to execute Event Viewer? What process i
    12·1 answer
  • What is the reasoning you would write an inquiry to a company?
    5·2 answers
  • Davingould1115...................answer 2​
    11·2 answers
  • You are designing an exciting new adventure game and you want to attempt to explain where items that are carried by the player a
    6·1 answer
  • Why does my roku tv keep disconnecting from the internet.
    13·1 answer
  • Between the div tags below, type the code for a link to the second.html page. Use "Go to the Second Page" as the link text
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!