Book Store in Java

Book Store in Java:-

package sifatOne;

import java.util.Scanner;

public class SifatTwo {//SifatTwo  class name
static Scanner input=new Scanner(System.in);


static String[] books= {"java","C","Python"};
static final double studentDiscount=0.3;
static final double teacherDiscount=0.4;
static final double alienDiscount=0.0;


public static void main(String[] args) {
prln("...WELCOME TO OUR BOOKSTOR...");
prln("Which book do you want? \n Ans: ");
String userChoice=input.nextLine();

if(books[0].toLowerCase().equals(userChoice.toLowerCase())) {
prln("you opted for "+ books[0]+" books");
calculatePrice(books[0]);


}else if(books[1].toLowerCase().equals(userChoice.toLowerCase())) {
prln("you opted for "+ books[1]+" books");
calculatePrice(books[1]);

}else if(books[2].toLowerCase().equals(userChoice.toLowerCase())) {
prln("you opted for "+ books[2]+" books");
calculatePrice(books[2]);

}else {
prln("Sorry! you dont have the book");
}



}

static void showPrice(double price) {
prln("Your total payable amount: "+price);
prln("\n.....THANK YOU FOR SHOPPING FROM OUR BOOKSTORE.....");
}


static void calculatePrice(String bookName) {
prln("Are you Student,Teacher,alien?\nAns: ");
String answer=input.nextLine();
double price = 200;

if(answer.toLowerCase().equals("teacher")) {
price=price-(price*teacherDiscount);
showPrice(price);

}else if(answer.toLowerCase().equals("student")) {
price=price-(price*studentDiscount);
showPrice(price);

}else if(answer.toLowerCase().equals("alien")) {
price=price-(price*alienDiscount);
showPrice(price);

}else {
prln("Sorry! we cant serve you");
}
}

static void prln(Object anyObject) {
System.out.println(anyObject);
}
static void pr(Object anyObject) {

System.out.println(anyObject);
}

}

Comments

  1. Custom titanium muffler recipe - TITANIA AUSTRALIA
    Custom titanium rainbow quartz titanium muffler leatherman charge titanium recipe in ceramic vs titanium TITANIA AUSTRALIA. titanium eyeglasses We created a recipe to test the quality of the habanero pepper jelly, habanero pepper jelly, titanium tools

    ReplyDelete

Post a Comment

Popular posts from this blog

For loop C++

VALENTINE DAY PROGRAME

Charecter & space founder in c program