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
You will hear a series of activities typical of Candela's life. After listening to and repeating each one, rewrite the entire se
Anon25 [30]

These are the complete sentences using the correct forms of the verbs conjugated in the simple present tense:

  1. Nosotros escribimos correos electrónicos desde diferentes partes del mundo.
  2. Tus padres deben tener mucho dinero.
  3. Sus amigas asisten al gimnasio todos los días.
  4. Tú no comprendes a las otras abuelitas.
  5. Yo también vivo la vida loca.
<h3 /><h3>What is the simple present tense?</h3>

The Spanish simple present tense (''presente del indicativo'' in Spanish) is used to talk about habitual situations, routines, universal truths and facts.

All the verbs in the exercise are conjugated using this tense.

I was able to find the complete instructions for the exercise online. Here are the sentences that had to be changed:

  1. Candela escribe correos electrónicos desde diferentes partes del mundo. (Nosotros)
  2. Candela debe tener mucho dinero. (Tus padres)
  3. Candela asiste al gimnasio todos los días. (Sus amigas)
  4. Candela no comprende a las otras abuelitas. (Tú)
  5. Candela vive la vida loca. (Yo también)

Check more information about the simple present tense here brainly.com/question/26436711

6 0
3 years ago
Which statement opens a text file so that you can retrieve the information it contains?
vesna_86 [32]

Answer:

Answered below

Explanation:

aFile = open("books.txt", "r")

This code uses the function open() which takes two parameters. The first parameter is the file name while the second parameter is the mode in which you are accessing the file.

The "r" mode opens the file in a reading state. That is, you can only read from the file. This code completes the reading process

aFile.read( )

The "w" mode opens the file so you can write to it and make changes.

The "a" mode opens the file so you can add contents to it.

3 0
3 years ago
Which is not a function associated with a motherboard? expansion slot. memory. processor. peripherals.
mars1129 [50]
Peripherals are not associated with the motherboard. 
4 0
3 years ago
Identify the possible error in each line. • For each line assume that the lines above it are part of the same code and have be
masya89 [10]
Twenty letters long okay
6 0
3 years ago
True Or False: The first computer to be introduced was the IBM PC in 1981<br> I think it's false.
nirvana33 [79]
False, It was ENIAC in 1946. I hope this helped.
8 0
4 years ago
Read 2 more answers
Other questions:
  • one business rule is that each project has one manager. Identify two (and no more than two) problems with the data structure or
    9·1 answer
  • True or false: its okay to sometimes compromise our values in order to resolve a conflict
    15·1 answer
  • Every time you are asked to work with others, you are being asked to:
    6·2 answers
  • Who initially developed what is now known as the internet?
    8·1 answer
  • Explain the role of the network layer and Internet protocol (IP) in order to make internetworking possible.
    8·1 answer
  • 4. How could you apply some of the ideas, principles, or structures of coding to fields of study, industries, or tasks outside o
    8·1 answer
  • What's one item in your house that represents you
    11·2 answers
  • Define the missing function. licenseNum is created as: (100000 * customID) licenseYear, where customID is a function parameter.
    12·1 answer
  • 1. What are the biggest password mistakes that people and companies make? How can you avoid those mistakes?
    11·1 answer
  • When did Microsoft released MS-Word 2016? S When did Microsoft released MS - Word 2016​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!