Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java. for beginners: A local public library needs a program to calculate t

ID: 3737024 • Letter: U

Question

Using Java. for beginners:

A local public library needs a program to calculate the overdue fines owed by its patrons. The library needs the clerk to enter the patron’s library card number, age of the patron, the number of days overdue for the item and the type of the item using the follow (enter 1, 2 or 3):

1.      Book

2.      Magazine

3.      DVD

Books that are overdue are assessed a fine of 50 cents per day. Magazines are assessed a fine of 25 cents per day. DVDs are assessed a fine of $1.50 a day. There is a maximum fine assessed of $5.00. Senior Citizens (over the age of 70) do not pay fines. Juvenile patrons (ages 6 through 17) pay a maximum fine of $1.00.

Once the fine has been calculated all information about the patron and the overdue material should be printed to the screen. Here is an example of the report that should be output:

Card number                                    12345

Age                                                   22

Item Type                                         DVD

Number of Days Overdue                2

Overdue Fine                                    $3.00

Fine adjustment reason                    (e.g, Senior citizen, Juvenile, exceed max)

Each time the program is executed it calculates the fine for a single item. If the user enters invalid data, then a message must be presented on the screen specifying the invalid information and the calculation is aborted.

   Run your program multiple times using the following information as input. After each run of the program save your entire console output screen to a text file as discussed in our labs.  

·       11111 is 75 years old and has an overdue magazine. The magazine is 1 day overdue.

·       22222 is 30 years old and has an overdue magazine. The magazine is 10 days overdue.

·       33333 is 10 years old and has an overdue DVD. The DVD is 2 days overdue.

·       44444 is 50 years old and has an overdue DVD. The DVD is 2 days overdue.

·       55555 is 20 years old and has an overdue book. The book is 60 days overdue.

66666 is 15 years old and has an overdue magazine. The magazine is 3 days overdue.

Explanation / Answer

import java.util.Scanner;

public class libraryfine

{

public static void main(String[] args)

{

int card_no,age,itemtype,days_overdue;    // variables defined

double overdue;

Scanner sc=new Scanner(System.in);

System.out.println("enter card no"); // input of data

card_no=input.nextInt();

System.out.println("enter age");

age=input.nextInt();

System.out.println("enter the type of item");

itemtype=input.nextInt();

System.out.println("enter the overdue no of days");

days_overdue=input.nextInt();

if(itemtype==1)

{

overdue=days_overdue*0.50; //calculation of fine

}

else if(itemtype==2)

{

overdue=days_overdue*0.25;

}

else if(itemtype==3)

{

overdue=days_overdue*1.50;

}

if(age>70)

{

overdue==0;

}

else if(age<6 && age>17)

{

overdue=1.0;

}

System.out.println("card no is" +card_no);

System.out.println("age is" +age);

System.out.println("overdue no of days are" +days_overdue);

if(itemtype==1)

{

System.out.println("the type of item is book");

}

else if(itemtype==2)

{

System.out.println("the type of item is magazine");

}

else if(itemtype==3)

{

System.out.println("the type of item is DVD");

}

else if(itemtype<1 && itemtype>3)

{

System.out.println("error");

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote