/**
Saadman's ISU
**/
import java.io.*;
import java.util.*;
public class ISU
{
public static void main (String[]args)
{
//Keyboard Initialization
Scanner kbin = new Scanner(System.in);
//Variable Inititialization & Declaration;
String list[] = new String [21];
int price1 = 30;
int price2 = 20;
int price3 = 25;
int price4 = 15;
int price5 = 29;
int price6 = 34;
int price7 = 49;
int price8 = 32;
int price9 = 50;
int price10 = 17;
int price11 = 20;
int price12 = 35;
int price13 = 42;
int price14 = 36;
int price15 = 38;
int price16 = 55;
int price17 = 17;
int price18 = 21;
int price19 = 22;
int price20 = 21;
int j=21;
int invalid=0;
double totalcost=0;
double discount1 = 0.10;
double discount2 = 0.15;
double tax = 0.13;
String a = "Your total price is: ";
String b = "(With Discount)";
int choice;
list [0] = "Harry Potter";
list [1] = "Programming For Beginners";
list [2] = "Life Of Pi";
list [3] = "The Hunger Games";
list [4] = "Eragon";
list [5] = "A Lesson Before Dying";
list [6] = "David Copperfield";
list [7] = "Murder On 10th Street";
list [8] = "Easy Recipes";
list [9] = "Beginners Guide To Web Design";
list [10] = "Twilight";
list [11] = "Kids Stories Collection";
list [12] = "Catcher In The Rye";
list [13] = "Chronicles Of Narnia";
list [14] = "History Of Computers";
list [15] = "Photoshop For Dummies";
list [16] = "Complete Idiot's Guide To Learning Guitar";
list [17] = "The Alchemist";
list [18] = "Diary Of A Wimpy Kid";
list [19] = "The Lovely Bones";
//Display Menu
System.out.println("\n\n\t\t************* *************");
System.out.println("\t\t* * * *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* ** *");
System.out.println("\t\t* * * *");
System.out.println("\t\t************* *************");
System.out.println("\n");
System.out.println("\t\tWELCOME TO SAADMAN'S BOOK STORE!");
System.out.println("\tCheck out our latest offers on select books!");
System.out.println("\n\n\tThe Hunger Games: 10% Off!");
System.out.println("\n\tEragon: 15% Off!");
//Input;
choice = 1;
while (choice == 1) {
if(j==21)
{
System.out.println("\n\n\tWhat Book would you like to search? : ");
System.out.println
("\n");
System.out.print(" ");
String Target = kbin.nextLine();
//Processing;
for (int i=0; i<20; i++)
if (list[i] != null && (list[i].equals(Target))){
System.out.println("\n\n");
invalid=1;
j=i;
System.out.print("\tYou chose: " + list[i]);
}
System.out.println("\n");
if(invalid==1)
{
//Output;
if (list[j] != null && (list[j].equals(list[0]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price1);
//System.out.println("\n");
totalcost = (price1+(price1*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
} else if (list[j] != null && (list[j].equals(list[1]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price2);
//System.out.println("\n");
totalcost = (price2+(price2*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
} else if (list[j] != null && (list[j].equals(list[2]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price3);
//System.out.println("\n");
totalcost = (price3+(price3*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
} else if (list[j] != null && (list[j].equals(list[3]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price4);
//System.out.println("\n");
totalcost = (price4 + (((price4) - (price4*discount1))*tax));
System.out.printf("%n%n\t%s%.2f%s", a , totalcost , b);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[4]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price5);
//System.out.println("\n");
totalcost = (price5 + (((price5) - (price5*discount2))*tax));
System.out.printf("%n%n\t%s%.2f%s", a , totalcost , b);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[5]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price6);
//System.out.println("\n");
totalcost = (price6+(price6*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[6]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price7);
//System.out.println("\n");
totalcost = (price7+(price7*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[7]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price8);
//System.out.println("\n");
totalcost = (price8+(price8*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[8]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price9);
//System.out.println("\n");
totalcost = (price9+(price9*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[9]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price10);
//System.out.println("\n");
totalcost = (price10+(price10*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[10]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price11);
//System.out.println("\n");
totalcost = (price11+(price11*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[11]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price12);
//System.out.println("\n");
totalcost = (price12+(price12*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[12]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price13);
//System.out.println("\n");
totalcost = (price13+(price13*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[13]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price14);
//System.out.println("\n");
totalcost = (price14+(price14*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[14]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price15);
//System.out.println("\n");
totalcost = (price15+(price15*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[15]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price16);
//System.out.println("\n");
totalcost = (price16+(price16*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[16]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price17);
//System.out.println("\n");
totalcost = (price17+(price17*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[17]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price18);
//System.out.println("\n");
totalcost = (price18+(price18*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[18]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price19);
//System.out.println("\n");
totalcost = (price19+(price19*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
}else if (list[j] != null && (list[j].equals(list[19]))){
System.out.println("\n");
try {
Thread.sleep(2300);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
System.out.print("\tPrice of book: $" + price20);
//System.out.println("\n");
totalcost = (price20+(price20*tax));
System.out.printf("%n%n\t%s%.2f", a , totalcost);
System.out.println("\n");
} else
System.out.println("\n\tThis does not exist in our shop!");
}
}
System.out.println("\n\tDo want to continue shopping? ");
System.out.println("\n\n\tPress 1 for 'Yes' or 0 for 'No' ");
System.out.print(" ");
choice = kbin.nextInt();
choice = 2;
while (choice == 2) {
if (choice == 1){
choice = 1;
} else if (choice == 0) {
System.out.println("\n\tThank you for shopping here");
System.out.println("\n\n");
System.exi
}else if (choice != 1 && choice != 0) {
System.out.println("\n\tInput invalid. Please try again. ");
System.out.println("\n\n");
choice = 2;
}
}
}
//System.exit(0);
} //end main;
} // end class;
JustLeftRavenholm 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JustLeftRavenholm 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JustLeftRavenholm 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JustLeftRavenholm 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JustLeftRavenholm 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.