import java.io.*;
import java.util.*;
class Book{
public static int number;
public static String author;
public static String title;
public static int stock;
public static double price;
Book(){
number=0;
author="";
title="";
stock=0;
price=0.0;
}
Book(int number,String author, String title, int Stock, double price){
this.number=number;
this.author=author;
this.title=title;
this.stock=stock;
this.price=price;
}
public int getNumber(){
return this.number;
}
public String getAuthor(){
return this.author;
}
public String getTitle(){
return this.title;
}
public int getStock(){
return this.stock;
}
public double getPrice(){
return this.price;
}
}
public class BookShop extends Book{
static Scanner input = new Scanner(System.in);
static ArrayList<Integer>listNumber = new ArrayList<>(50);
static ArrayList<String>listAuthor = new ArrayList<>(50);
static ArrayList<String>listTitle = new ArrayList<>(50);
static ArrayList<Integer>listStock = new ArrayList<>(50);
static ArrayList<Double>listPrice = new ArrayList<>(50);
static void Menu(){
System.out.println("\t\tWELCOME TO GIT GUD BOOKSHOP");
System.out.println("Please choose the transaction you want to make\n\n\n");
System.out.println("[1] Display current book(s) on stock");
System.out.println("[2] Add book(s) to cars");
System.out.println("[3] Remove book(s) from cart");
System.out.println("[4] Proceed to checkout");
System.out.println("[5] Exit");
}
static void Header(){
System.out.println("No./t Author/t/t/t Title/t/t/t/t/t Stock/t/t Price");
}
static void Booklist(){
for(int i=0;i<listNumber.size();i++){
System.out.println(+listNumber.get(i)+"\t"+listAuthor.get(i)+"\t"+listTitle.get(i)+"\t"+listStock.get(i)+"\t"+listPrice.get(i));
}
}
static int removeBook(){
System.out.print("Enter number: ");
int removeNumber=input.nextInt();
listNumber.remove(removeNumber);
listAuthor.remove(removeNumber);
listTitle.remove(removeNumber);
listPrice.remove(removeNumber);
return removeNumber;
}
public static void main(String args[]) throws IOException{
int a,b;
char ans;
listNumber.add(1);
listAuthor.add("J.K Rowling");
listTitle.add("Harry Potter and the Philosopher's Stone");
listStock.add(4);
listPrice.add(7.99);
listNumber.add(2);
listAuthor.add("J.K Rowling");
listTitle.add("Harry Potter and the Chamber of Secretse");
listStock.add(1);
listPrice.add(7.99);
listNumber.add(3);
listAuthor.add("J.K Rowling");
listTitle.add("Harry Potter and the Prisoner of Azkaban");
listStock.add(1);
listPrice.add(9.99);
listNumber.add(4);
listAuthor.add("J.K Rowling");
listTitle.add("Harry Potter and the Goblet of Fire");
listStock.add(2);
listPrice.add(7.99);
Menu();
do{
Menu();
a=input.nextInt();
switch(a){
case 1:
Header();
Booklist();
break;
case 2:
removeBook();
break;
case 3:
removeBook();
break;
case 4:
case 5:
break;
default:
break;
}
System.out.print("\nBack to main menu? [Y/N] ");
ans=input.next(".").charAt(0);
}while (ans=='Y' || ans=='y');
System.out.println("Thank you for shopping!");
}
}
what seems to be the problem with our codes, its giving an "Error: Could not find or load main class bookShop"
we are using the cmd method to run java programs. compiling it give no error at at all "javac bookShop.java" works without error but when i do try to run it using "java bookShop" its when the error occurs