publc static void renewBook(String bookName, String userName, intday, int month)
ID: 3611690 • Letter: P
Question
publc static void renewBook(String bookName, String userName, intday, int month){
}
Specify the names and types of the input parameters
Now, complete the body of the method so that it prints theinformation about the renewal of the book on the terminal window(standard output). For instance, when invoked with "Harry Potter"as a book name, "John Smith" as a user name, 23 for the day and 2for the month it prints:
The book Harry Potter is renewed for john Smith until 23/2
Write now a calling method for renew book.
Choose your parameters.
Explanation / Answer
publc static void renewBook(String bookName, String userName, intday, int month){} Specify the names and types of the input parameters The input parameters are: bookName ---- this is of type String userName ---- this is of typeStringday ----this is of type int (integer) month ---- this is of type int (integer) Body of the function: publc static void renewBook(String bookName,String userName, int day, int month) { System.out.println("The book " + bookName + " is renewed for " +userName + " until " + day +"/" + month); } /*** The java code for the program is given below. The code also includes a calling method for renewBook(....) */ import java.io.*; import java.lang.*; import java.util.*; public class RenewBook{ public static void renewBook(String bookName, String userName, intday, int month) { System.out.println("The book " + bookName + " isrenewed for " + userName + " until " + day +"/" + month); } public static void callRenewBook() { try{ System.out.println("Enter the bookName:"); String bookName = (newBufferedReader(new InputStreamReader(System.in)).readLine()); System.out.println("Enter the username:"); String userName = (newBufferedReader(new InputStreamReader(System.in)).readLine()); System.out.println("Enter theday:"); int day =Integer.parseInt (new BufferedReader(newInputStreamReader(System.in)).readLine()); System.out.println("Enter the month:"); int month = Integer.parseInt (newBufferedReader(new InputStreamReader(System.in)).readLine()); renewBook(bookName, userName, day ,month); } catch (Exception e){ e.printStackTrace(); } } public static void main(String [] args) { callRenewBook(); } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.