Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-092-introduction-to-programming-in-java-january-iap-2010/lecture-notes/
- import java.util.Scanner;
- public class bookLibrayModel {
- public static void main(String args[]){
- String[] books = {"Plants", "Dictionary", "Math", "Science"};
- boolean available= true;
- int bookNum = 0;
- int action;
- books[0] = available;
- books[1] = available;
- books[2] = available;
- books[3] = available;
- Scanner myScanner = new Scanner(System.in);
- System.out.println("Please select a numbered option: \n 1.Check availablity of books \n 2.Return a book");
- action = myScanner.nextInt();
- if(action == 1){
- System.out.println("Please choose a numbered book: \n 1.Plants \n 2.Dictionary \n 3.Math \n 4.Science");
- bookNum = myScanner.nextInt();
- }if(bookNum == 1){
- System.out.println("Book is available:"+ books[0]);
- }else if(bookNum == 2){
- System.out.println("Book is available:"+ books[1]);
- }else if(bookNum == 3){
- System.out.println("Book is available:"+ books[2]);
- }else if(bookNum == 4){
- System.out.println("Book is availavble:"+ books[3]);
- }
- if(action == 2){
- System.out.println("Please select a numbered book to return: \n1.Plants \n2.Dictionary \n3.Math \n4.Science");
- bookNum = myScanner.nextInt();
- }if(bookNum == 1){
- available = !available;
- System.out.println(books[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement