Question

Using visual studio C# Console App (.Net Framework): Create a Console application for a library and...

Using visual studio C# Console App (.Net Framework):

Create a Console application for a library and name it FineForOverdueBooks. The Main () method asks the user to input the number of books that are overdue and the number of days they are overdue. Pass those values to a method 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.

1. Create a Console application. The Main () method, the user is prompted to enter the number of books that are overdue, and the number of days they are overdue.

2. Create a user-defined method to compute the fine for overdue books. This method will receive the number of overdue books and the number of days the books are overdue as parameters from the Main() method. Then this method will calculate the fine and display it.

3. Compile and test the program to make sure there is no syntax error.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code -


using System;
class HelloWorld {
static void Main() {
//ask user to enter number of books
Console.WriteLine("Enter number of books that are overdue ");
int books = Convert.ToInt32(Console.ReadLine());
//ask user to enter number of days
Console.WriteLine("Enter number of days they are overdue ");
int days = Convert.ToInt32(Console.ReadLine());
//call function calculate fine
calculateFine(books,days);
}
private static void calculateFine(int books,int days){
int fine = 0;
//check if days are greater then 7
if(days>7)
fine = books*10*7 + books*20*(days-7);
//else calculate fine directly
else
fine = books*10*days;
Console.WriteLine("Fine"+fine);
}
}

Screenshots -

Add a comment
Know the answer?
Add Answer to:
Using visual studio C# Console App (.Net Framework): Create a Console application for a library and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT