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 must be true before a motherboard can take advantage of the triple memory channels on the board?
sergeinik [125]

Answer:

The motherboard must be configured to accept a particular type of memory.

Explanation:

The motherboard must be configured to accept a particular type of memory, especially when dealing with multi-channel memory. On motherboard, different modes can be configured to run simultaneously . For motherboard to take advantage of  the triple memory channels on the board. You can also check the manual that came with the motherboard to know how to configure it.

7 0
2 years ago
Use the following data definitions data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE" What will
Elena-2011 [213]

Answer:

<em>Given Data:</em>

<em>myBytes BYTE 10h, 20h, 30h, 40h </em>

<em>myWords WORD 3 DUP(?), 2000h </em>

<em>myString BYTE "ABCDE"</em>

<em />

Based on the data that we are given we can conclude that:

(a).     a. EAX = 1

         b. EAX = 4

         c. EAX = 4

         d. EAX = 2

         e. EAX = 4

         f. EAX = 8

         g. EAX = 5

8 0
3 years ago
Class 00 rubber gloves are used when working with voltages less than​ _____.
Radda [10]
Answer: 500 volts AC, 750 volts DC
Class 00 rubber gloves are given the color "beige" based on the color code of rubber gloves.
The proof test voltage for this class of rubber gloves is 2500 volts of AC voltage and 10000 volts of DC voltage
4 0
3 years ago
You are gong to buy a computer but first you want to do some research to help you select the best model for your needs
DerKrebs [107]

Answer:

Research what kind of computer you want.

Explanation:

I don't know exactly what you are asking here but when doing research you have got to know what you want like how much ram you want, how much storage you want, what brand of computer you want, what core processor you want, and what graphics card you want. You also have to decide if you want a laptop or a full sized desk top computer.

8 0
3 years ago
Jose has 3/5 kilogram of peppermints and 2/3 kilogram of candy canes. How many kilograms of candy does he have?
yarga [219]

Answer:

\frac{19}{15}\\

≅ 1.267

Explanation:

\frac{3}{5} +\frac{2}{3} \\\\= \frac{9}{15} + \frac{10}{15} \\\\= \frac{9+10}{15} \\\\= \frac{19}{15} \\\\= 1.267

6 0
2 years ago
Other questions:
  • What is the magnitude of the largest positive value you can place in a bool? a char? an int? a float?
    14·1 answer
  • Can someone help me with this one
    9·2 answers
  • Generally considered to be the most important information security policies, what item below defines the actions a user may perf
    11·1 answer
  • A computer has been stored, uncovered, in a dusty closet for several months. Why might this situation cause the operating system
    13·1 answer
  • Which of the following actions is an example of "window dressing?" a. Using some of the firm’s cash to reduce long-term debt. b.
    13·1 answer
  • Which among the following choices is correct based on the two statements listed below? Statement 1: When the lexical analyzer sc
    12·1 answer
  • Why do you think that so many of these sources have similar names?
    9·1 answer
  • What feature should be used before a document is printed
    8·1 answer
  • Which is the least technically experienced technical support group?
    7·1 answer
  • Differentiate between tabular and column form layout​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!