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
Match each sentence to the type of imperialism it describes.
tankabanditka [31]

There is nothing to match?

5 0
3 years ago
Now that you have learned the basics of acquiring relevant information through research, it's time to put your skills to work.
MakcuM [25]

From the information given, the quickest way to be able to access the information will be C. Go to the FAQ page of the tablet.

<h3>Solving the research.</h3>

From the complete information, in order to use Photoshop, be should watch a tutorial. When Hannah is setting up her printer but doesn't know where to attach the cables, it's important to read the user's manual.

Also, when Mariana wants an informal research about smartphones, she should read the comments on a vendor bulletin board.

Learn more about researches on:

brainly.com/question/25257437

3 0
2 years ago
Write a program that prompts the user to enter an oligonucleotide sequence, such as TATGAGCCCGTA.
Alexxx [7]

Answer:

Explanation:

The following code is written in Python. It continues looping and asking the user for an oligonucleotide sequence and as long as it is valid it outputs the reverse complement of the sequence. Otherwise it exits the loop

letters = {'A', 'C', 'G', 'T'}

reloop = True

while reloop:

   sequence = input("Enter oligonucleotide sequence: ")

   for x in sequence:

       if x not in letters:

           reloop = False;

           break

   if reloop == False:

       break

   newSequence = ""

   for x in sequence:

       if x == 'A':

           newSequence += 'T'

       elif x == 'T':

           newSequence += 'A'

       elif x == 'C':

           newSequence += 'G'

       elif x == 'G':

           newSequence += 'C'

   print("Reverse Complement: " + newSequence)

7 0
2 years ago
A(n) _______________ loop usually occurs when the programmer forgets to write code inside the loop that makes the test condition
Serggg [28]
Infinite





,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
5 0
3 years ago
In distributed dos attacks, the attacker sends messages directly to ________. bots the intended victim of the dos attack backdoo
kirill115 [55]
The word DoS refers to the Disk Operating System. In the case given above, if it happens that there is a distributed DoS attack, the attacker then sends messages directly to the BOTS. Bots refer to internet or web robots. Hope this answer helps. The answer is the first option.
4 0
3 years ago
Other questions:
  • What were precomputed tables and why were they necessary?​
    12·2 answers
  • How does scarcity affect what gets produced
    5·1 answer
  • Stress results from _______. A. Outside stimulus b. Internal stimulus c. Outside calm d. Internal calm
    12·2 answers
  • Help what is a computer made from (computer class question)!!
    9·1 answer
  • Was the type writer the first part of the keyboard? ​
    8·1 answer
  • Who initially developed what is now known as the internet?
    5·1 answer
  • PLS HELP ILL GIVE BRAINLY- (enter the answer) Microsoft _________ is an example of a desktop publishing software
    13·2 answers
  • If you delete a conversation many times with someone like this, will you stop receiving messages from them?
    13·1 answer
  • PLS HURRY<br> Look at the image below
    8·1 answer
  • Is e commerce a challenge or opportunity to the freight forwarder
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!