2 Replies - 211 Views - Last Post: 06 June 2020 - 07:07 AM Rate Topic: -----

#1 PorkRibs23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-June 20

So i need create like an cashier program using java code

Posted 06 June 2020 - 01:39 AM

So i need create like an cashier program using java code and have more than one class and later the class will can run
INHERE I HAVE 4 CLASSES (SUBMENU,MAINMENU,ITEM,AND INFORMATION
SO THIS IS MY CODE
SUB MENU CLASS:
//*******************************************************************
// Welcome to Ronald's Grocery Sub Menu Program Code
//*******************************************************************

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
class SubMenu{
	public void printSubMenu(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
	    new SubMenu().printDateAndTime();
		System.out.println("=====================================");
		System.out.println("--------------SUB MENU---------------");
		System.out.println("1. Price List");
		System.out.println("2. More Information");
		System.out.println("0. Exit Program");
		System.out.println("=====================================");
		System.out.println("Please enter your choice: \n");
	}
	public void printExit(){
		System.out.println("=====================================");
		System.out.println("          THANK YOU FOR USING        ");
		System.out.println("         Ronald's Groceries Mart     ");
		System.out.println("   Admin: Ronald J      ID: 0332166  ");
		new SubMenu().printDateAndTime();
		System.out.println("=====================================");
		}
	public void printError(){
		System.out.println("=====================================");
		System.out.println("ERROR!!! Please Choose another option");
		System.out.println("=====================================");
		System.out.println("Please enter your choice: \n");
		}
	public void printDateAndTime() {
		 LocalDateTime myDateObj = LocalDateTime.now();
		 DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
		 String formattedDate = myDateObj.format(myFormatObj);
		 System.out.println("      " + formattedDate);
	}
	public void printAddMoreItem(){
		System.out.println("Do you want add more item?");
		System.out.println("(1=yes/0=no)");
		}
	public void printQty(){
		System.out.println("Enter quantity");
		}
	public void printOption(){
		System.out.println("Please enter the option you want: ");
		}
	public void printPriceList(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
		System.out.println("=====================================");
		System.out.println("-------------PRICE LIST--------------");
		System.out.println("1. Noodles");
		System.out.println("2. Beer");
		System.out.println("3. Snacks");
		System.out.println("=====================================");
		System.out.println("Please enter the option you want: ");
	}	
	public void printSnacks(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
		System.out.println("=====================================");
        System.out.println("---------------SNACKS----------------");
        System.out.println("------------Add to Chart-------------");
       	System.out.println("1. Tic Tac \t         RM 5.00");
       	System.out.println("2. Chitato \t         RM 6.00");
        System.out.println("3. Tango \t         RM 4.00");
        System.out.println("4. Mamee Monster         RM 2.00");
       	System.out.println("5. Super Ring \t         RM 3.00");
       	System.out.println("=====================================");
       	System.out.println("Please enter the option you want: ");
	}
	public void printBeer(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
		System.out.println("=====================================");
        System.out.println("-------------Beer--------------------");
        System.out.println("----------Add to Chart---------------");
        System.out.println("1. Bali Hai\t        RM 10.00");
        System.out.println("2. Beer Bintang\t        RM 12.00");
        System.out.println("3. Heineken\t        RM 18.00");
        System.out.println("4. Guinness\t        RM 20.00");
        System.out.println("5. Corona Extra\t        RM 25.00");
        System.out.println("=====================================");
        System.out.println("Please enter the option you want: ");
	}
	public void printNoodle(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
		System.out.println("=====================================");
    	System.out.println("---------------Noodles---------------");
    	System.out.println("------------Add to Chart-------------");
		System.out.println("1. Maggi Instant Noodle\t  RM 3.00");
		System.out.println("2. Samyang Ramen\t  RM 4.00");
		System.out.println("3. Indomie Instant Noodle RM 5.00");
		System.out.println("4. Tonkutsu Ramen\t  RM 6.00");
		System.out.println("5. Mama Instant Noodle\t  RM 7.00");
		System.out.println("=====================================");
		System.out.println("Please enter the option you want: ");
	}
	public void printInformation(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
		System.out.println("=====================================");
		System.out.println("-------MORE INFORMATION ABOUT--------");
		System.out.println("1. Noodles");
		System.out.println("2. Beer");
		System.out.println("3. Snacks");
		System.out.println("=====================================");
		System.out.println("Please enter the option you want: ");
	}
	public void printInfoNoodle(){
		System.out.println("=====================================");
		System.out.println("   Welcome to Ronald's Grocery Mart  ");
	    System.out.println("   Admin: Ronald J      ID: 0332166  ");
		System.out.println("=====================================");
		System.out.println("-----Information About Noodles-------");
		System.out.println("1. Maggi Instant Noodle ");
		System.out.println("2. Samyang Ramen");
		System.out.println("3. Indomie Instant Noodle");
		System.out.println("4. Tonkutsu Ramen");
		System.out.println("5. Mama Instant Noodle");
		System.out.println("====================================");
		System.out.println("Please enter the option you want: ");
	}
	public void printInfoBeer(){
		System.out.println("====================================");
		System.out.println("  Welcome to Ronald's Grocery Mart  ");
		System.out.println("====================================");
		System.out.println("------Information About Beer--------");
		System.out.println("1. Bali Hai ");
		System.out.println("2. Beer Bintang");
		System.out.println("3. Heineken");
		System.out.println("4. Guinness");
		System.out.println("5. Corona Extra");
		System.out.println("====================================");
		System.out.println("Please enter the option you want: ");
	}
	public void printInfoSnacks(){
		System.out.println("====================================");
		System.out.println("  Welcome to Ronald's Grocery Mart  ");
		System.out.println("====================================");
		System.out.println("-----Information About Snacks-------");
		System.out.println("1. Tic Tac");
		System.out.println("2. Chitato");
		System.out.println("3. Tango");
		System.out.println("4. Mamee Monster");
		System.out.println("5. Super Ring");
		System.out.println("====================================");
		System.out.println("Please enter the option you want: ");
	}
}


MAIN MENU CLASS:
//*******************************************************************
// Welcome to Ronald's Grocery Main Menu Program Code
//*******************************************************************
//package AssignmentRonaldGroceries;
//import AssignmentRonaldGroceries.MainMenu;
//import AssignmentRonaldGroceries.Item;
//import AssignmentRonaldGroceries.Information;

import java.util.Scanner;
public class RonaldGroceries {
	public static void main(String[] args) {
		int SubMenu = 0; //THE FIRST INPUT USER WILL SEE 
		double PriceList=0;//SHOW PRICE LSIT ITEM IN THIS STORE
		double NoodleList = 0;
		double BeerList = 0;
		double SnacksList = 0;
		int information = 0; //INFORMATION MENU
		int infoNoodle=0;
		int infoBeer=0;
		int infoSnacks=0;
		Scanner input = new Scanner(System.in);
		
		new SubMenu().printSubMenu();
		SubMenu = input.nextInt(); // USER NEED TO PICK ONE NUMBER 
		
		Item Item = new Item();
	    System.out.println(Item);
	    
	    Information Information = new Information();
	    System.out.println(Information);
	//-------------------------------------------------------------------------------------------------------------------//
	//-------------------------------------------------------------------------------------------------------------------//
		
			if(SubMenu == 1) {//PRICE LIST MENU (SHOW ALL THE ITEM PRICE) USER ALLOW TO INPUT THEIR ITEMS AND QTY 
				new SubMenu().printPriceList();
				if (PriceList > 3) {
					new SubMenu().printError();
					PriceList = input.nextInt();
				}
			}
			if (PriceList ==1) {
				new SubMenu().printNoodle();
			    if (NoodleList > 5) {
			    	new SubMenu().printError();
			    }
			}
			else if (PriceList ==2) {
				new SubMenu().printBeer();
				if (BeerList > 5) {
			    	new SubMenu().printError();
			    }
			}
			else if (PriceList ==3) {
				new SubMenu().printSnacks();
				if (SnacksList > 5) {
			    	new SubMenu().printError();
			    }
			}
			
	//-------------------------------------------------------------------------------------------------------------------//
	//-------------------------------------------------------------------------------------------------------------------//
			
			if (SubMenu == 2) {	//PRINT OUT MORE INFORMATION ABOUT PRODUCT (USER ALLOW TO PICK ONE WHERE USER WANT TO GO)
				new SubMenu().printInformation();
				if (information > 3) {
					new SubMenu().printError();
					information = input.nextInt();
				}
			}
			if (information == 1) {
				new SubMenu().printInfoNoodle();
				if (infoNoodle > 5) {
					new SubMenu().printError();
				}
			}
 
			else if (information == 2) {
				new SubMenu().printInfoBeer();
				if (infoBeer > 5) {
					new SubMenu().printError();
				}
			}
			else if (information == 3) {
				new SubMenu().printInfoSnacks();
				if (infoSnacks > 5) {
					new SubMenu().printError();
				}
			}
				
	//-------------------------------------------------------------------------------------------------------------------//
	//-------------------------------------------------------------------------------------------------------------------//
			
			if(SubMenu == 0) {
			     new SubMenu().printExit();// EXIT PROGRAM
			}
	}
}

ITEM CLASS
import java.util.Scanner;

public class Item {
	int SubMenu; //THE FIRST INPUT USER WILL SEE 
	//Information Information; //INFORMATION MENU
	double NoodleList;
	double BeerList;
	double SnacksList;
	double PriceList = 0;
	public void Item(int Item) {
	Scanner input = new Scanner(System.in);
		if (NoodleList == 1) {
			System.out.println("You've ordered Maggi Instant Noodle");
			NoodleList= 3.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				NoodleList= input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * NoodleList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (NoodleList == 2) {
			System.out.println("You've ordered Samyang Ramen");
			NoodleList= 4.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				NoodleList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * NoodleList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (NoodleList == 3) {
			System.out.println("You've ordered Indomie Instant Noodle");
			NoodleList = 5.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				NoodleList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * NoodleList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (NoodleList== 4) {
			System.out.println("You've ordered Tonkutsu Ramen");
			NoodleList = 6.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				NoodleList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * NoodleList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (NoodleList == 5) {
			System.out.println("You've ordered Mama Instant Noodle");
			NoodleList = 7.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				NoodleList= input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * NoodleList);
				System.out.println("Total RM " + total );
			}	
		}    
		if (BeerList == 1) {
			System.out.println("You've ordered Bali Hai");
			BeerList = 10.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				BeerList = input.nextInt(); 
				new SubMenu().printQty();
				qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * BeerList);
				System.out.println("Total RM " + total );
			}	
		}
		else if (BeerList == 2) {
			System.out.println("You've ordered Beer Bintang");
			BeerList = 12.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				BeerList= input.nextInt(); 
				new SubMenu().printQty();
				qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * BeerList);
				System.out.println("Total RM " + total );
			}	
		}
		else if (BeerList == 3) {
			System.out.println("You've ordered Heineken");
			BeerList = 18.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				BeerList = input.nextInt(); 
				new SubMenu().printQty();
				qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * BeerList);
				System.out.println("Total RM " + total );
			}	
		}
		else if (BeerList == 4) {
			System.out.println("You've ordered Guinness");
			BeerList = 20.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				BeerList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * BeerList);
				System.out.println("Total RM " + total );
			}	
		}
		else if (BeerList == 5) {
			System.out.println("You've ordered Corona Extra");
			BeerList = 25.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				BeerList = input.nextInt(); 
				new SubMenu().printQty();
				qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * BeerList);
				System.out.println("Total RM " + total );
			}	
		}	
		if (SnacksList == 1) {
			System.out.println("You've ordered Tic Tac");
			SnacksList = 5.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				SnacksList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * SnacksList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (SnacksList == 2) {
			System.out.println("You've ordered Chitato");
			SnacksList = 6.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				SnacksList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * SnacksList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (SnacksList == 3) {
			System.out.println("You've ordered Tango");
			SnacksList = 4.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				SnacksList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * SnacksList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (SnacksList == 4) {
			System.out.println("You've ordered Mamee Monster");
			SnacksList = 2.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				SnacksList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * SnacksList);
				System.out.println("Total RM " + total );
			}	
		}
	    else if (SnacksList == 5) {
			System.out.println("You've ordered Super Ring");
			SnacksList= 3.00;
			new SubMenu().printQty();
			int qty = input.nextInt();
			new SubMenu().printAddMoreItem();
			int moreItem  = input.nextInt();
			if (moreItem == 1) {
				new SubMenu().printOption();
				SnacksList = input.nextInt(); 
				new SubMenu().printQty();
			    qty = input.nextInt();
			}
			else if (moreItem == 0) {
				new SubMenu().printExit();
				double total = (qty * SnacksList);
				System.out.println("Total RM " + total );
				
			}
	    }
	}
}
INFORMATION CLASS
import java.util.Scanner;

public class Information {
	int SubMenu = 0; //THE FIRST INPUT USER WILL SEE 
	int information; //INFORMATION MENU
	int infoNoodle = 0;
	int infoBeer = 0;
	int infoSnacks = 0; 
	int stocks = 80;
	public void Information() {
	Scanner input = new Scanner(System.in);
	if (infoNoodle == 1) {
	    System.out.println("=========================================================================");
	    System.out.println("1. Information about Maggi Instant Noodle: ");
		System.out.println("Maggi is an international brand of noodles");
		System.out.println("that originated in Switzerland in late 19th century");
		System.out.println("ORIGIN : Malaysia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another Noodles?");
		System.out.println("(1=yes/0=no)");
		infoNoodle  = input.nextInt();
		if (infoNoodle == 1) {
			new SubMenu().printInfoNoodle();
			infoNoodle = input.nextInt();
		}
		else if (infoNoodle == 0) {
			new SubMenu().printExit();
		}
	}
	else if (infoNoodle == 2) {
    	System.out.println("=========================================================================");
	   	System.out.println("2. Information about Samyang Ramen: ");
		System.out.println("Samyang Ramen is an Spicy Noodle From Korea, ");
		System.out.println("Samyang Ramen is a brand of ramyeon, produced by Samyang Food in South Korea since April 2012");
		System.out.println("ORIGIN : Korea");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another Noodles?");
		System.out.println("(1=yes/0=no)");
		infoNoodle  = input.nextInt();
		if (infoNoodle == 1) {
			new SubMenu().printInfoNoodle();
			infoNoodle = input.nextInt();
		}
		else if (infoNoodle == 0) {
			new SubMenu().printExit();
		}
	}
	else if (infoNoodle == 3) {
	   	System.out.println("=========================================================================");
	   	System.out.println("3. Information about Indomie Instant Food: ");
		System.out.println("Indomie is a brand of instant noodle produced by Indonesian");
		System.out.println("company PT Indofood CBP Sukses Makmur Tbk");
		System.out.println("ORIGIN : Indonesia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another Noodles?");
		System.out.println("(1=yes/0=no)");
		infoNoodle  = input.nextInt();
		if (infoNoodle == 1) {
			new SubMenu().printInfoNoodle();
			infoNoodle = input.nextInt();
		}
		else if (infoNoodle == 0) {
			new SubMenu().printExit();
		}
	}
	else if (infoNoodle == 4) {
	    System.out.println("=========================================================================");
	   	System.out.println("4. Information about Tonkutsu Ramen: ");
		System.out.println("Tonkutsu Ramen is an ramen from Japan.");
		System.out.println("The soup broth is based on pork bones and other ingredients");
		System.out.println("ORIGIN : Fukuoka, Japan");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another Noodles?");
		System.out.println("(1=yes/0=no)");
		infoNoodle  = input.nextInt();
		if (infoNoodle == 1) {
			new SubMenu().printInfoNoodle();
			infoNoodle = input.nextInt();
		}
		else if (infoNoodle == 0) {
			new SubMenu().printExit();
		}
	}	
	else if (infoNoodle == 5) {
    	System.out.println("=========================================================================");
    	System.out.println("5. Information about Mama Instant Noodle: ");
		System.out.println("Mama Instant Noodle is an Instant soups, ");
		System.out.println("including oriental style instant noodles");
		System.out.println("ORIGIN : Malaysia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		int inforMation  = input.nextInt();
		if (inforMation == 1) {
			new SubMenu().printInformation();
		    information = input.nextInt();
		    if (information > 5) {
		    	new SubMenu().printError();
		       	infoNoodle= input.nextInt();
			}
		}
		else if (inforMation == 0) {
			new SubMenu().printExit();
		}
	}
	if (infoBeer == 1) {
		System.out.println("=========================================================================");
		System.out.println("1. Information about Bali Hai: ");
		System.out.println("Bali Hai is a brand of Indonesian lager beer");
		System.out.println("produced by PT Bali Hai Brewery Indonesia since 1975");
		System.out.println("ORIGIN : Bali - Indonesia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoBeer  = input.nextInt();
		if (infoBeer == 1) {
			new SubMenu().printInfoBeer();
			infoBeer = input.nextInt();
		    if (information > 5) {
		    	new SubMenu().printError();
		       	infoNoodle= input.nextInt();
			}
		}
		else if (infoBeer == 0) {
			new SubMenu().printExit();
		}
    }			
	else if (infoBeer == 2) {
		System.out.println("=========================================================================");
		System.out.println("2. Information about Beer Bintang: ");
		System.out.println("Bintang Beer is a brand of beer from Indonesia,");
		System.out.println("Bintang Beer is a brand of beer from Indonesia and is produced by PT Multi Bintang Indonesia Tbk");
		System.out.println("ORIGIN : East Java - Indonesia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoBeer  = input.nextInt();
		if (infoBeer == 1) {
			new SubMenu().printInfoBeer();
			infoBeer = input.nextInt();
		    if (information > 5) {
		    	new SubMenu().printError();
		       	infoNoodle= input.nextInt();
			}
		}
		else if (infoBeer == 0) {
			new SubMenu().printExit();;
		}
    }	
	else if (infoBeer == 3) {
		System.out.println("=========================================================================");
		System.out.println("3. Information about Heineken: ");
		System.out.println("Heineken Lager Beer, or simply Heineken is a pale lager beer with");
		System.out.println("5% alcohol by volume produced by the Dutch brewing company Heineken International.");
		System.out.println("ORIGIN : Netherlands");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoBeer  = input.nextInt();
		if (infoBeer == 1) {
			new SubMenu().printInfoBeer();
			infoBeer = input.nextInt();
		    if (information > 5) {
		    	new SubMenu().printError();
		       	infoNoodle= input.nextInt();
			}
		}
		else if (infoBeer == 0) {
			new SubMenu().printExit();
		}
    }
	else if (infoBeer == 4) {
		System.out.println("=========================================================================");
		System.out.println("4. Information about Guinness: ");
		System.out.println("Guinness is a dark Irish dry stout that originated in the brewery of Arthur Guinness");
		System.out.println("at St. James's Gate, Dublin, Ireland, in 1759");
		System.out.println("It is one of the most successful alcohol brands worldwide");
		System.out.println("ORIGIN : Ireland");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoBeer  = input.nextInt();
		if (infoBeer == 1) {
			new SubMenu().printInfoBeer();
			infoBeer = input.nextInt();
		    if (information > 5) {
		    	new SubMenu().printError();
		       	infoNoodle= input.nextInt();
			}
		}
		else if (infoBeer == 0) {
			new SubMenu().printExit();
		}
    }
	else if (infoBeer == 5) {
		System.out.println("=========================================================================");
		System.out.println("5. Information about Corona Extra: ");
		System.out.println("Cervecería Modelo and owned by Belgian company AB InBev.");
		System.out.println("It is commonly served with a wedge");
		System.out.println("of lime or lemon in the neck of the bottle to add tartness and flavour.");
		System.out.println("ORIGIN : Mexico");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoBeer  = input.nextInt();
		if (infoBeer == 1) {
			new SubMenu().printInformation();
		    information = input.nextInt();
		    if (information > 5) {
		    	new SubMenu().printError();
		       	infoBeer= input.nextInt();
			}
		else if (infoBeer == 0) {
			new SubMenu().printExit();
		}
	}
	}
	if (infoSnacks == 1) {
		System.out.println("=========================================================================");
		System.out.println("1. Information about Tic Tac: ");
		System.out.println("Tic Tac is an peanut snacks From Indonesia");
		System.out.println("produced by PT Kacang Dua Kelinci Indonesia since 1998");
		System.out.println("ORIGIN : Indonesia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoSnacks  = input.nextInt();
		if (infoSnacks == 1) {
			new SubMenu().printInfoSnacks();
			information = input.nextInt();
		if (information > 5) {
			new SubMenu().printError();
			infoSnacks= input.nextInt();
		}
		else if (infoSnacks == 0) {
			new SubMenu().printExit();
		}
		}
	}
	else if (infoSnacks == 2) {
		System.out.println("=========================================================================");
		System.out.println("2. Information about Chitato: ");
		System.out.println("Chitato products are the catalysts that encourages our consumer to live life fearlessly");
		System.out.println("The real fresh potato with crunchiness like no other, and the wavy cut that preserve the flavour");
		System.out.println("ORIGIN : Indonesia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoSnacks  = input.nextInt();
		if (infoSnacks == 1) {
			new SubMenu().printInfoSnacks();
			information = input.nextInt();
		if (information > 5) {
			new SubMenu().printError();
			infoSnacks= input.nextInt();
		}
		else if (infoSnacks == 0) {
			new SubMenu().printExit();
		}
		}
	}
	else if (infoSnacks == 3) {
		System.out.println("=========================================================================");
		System.out.println("3. Information about Tango: ");
		System.out.println("Tango is an biscuit From Indonesia");
		System.out.println("and have sweat taste.");
		System.out.println("ORIGIN : Indonesia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoSnacks  = input.nextInt();
		if (infoSnacks == 1) {
			new SubMenu().printInfoSnacks();
			information = input.nextInt();
		if (information > 5) {
			new SubMenu().printError();
			infoSnacks= input.nextInt();
		}
			else if (infoSnacks == 0) {
				new SubMenu().printExit();
			}
		}
	}
	else if (infoSnacks == 4) {
		System.out.println("=========================================================================");
		System.out.println("4. Information about Mamee Monster: ");
		System.out.println("Mamee Monster is an dry noodle snacks From Malaysia");
		System.out.println("MAMEE Monster noodle snack has been the staple tasty and ");
		System.out.println("affordable treat for many Malaysians for the past 40 years.");
		System.out.println("ORIGIN : Malaysia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
			infoSnacks  = input.nextInt();
			if (infoSnacks == 1) {
				new SubMenu().printInfoSnacks();
				information = input.nextInt();
			if (information > 5) {
				new SubMenu().printError();
				infoSnacks= input.nextInt();
			}
			else if (infoSnacks == 0) {
				new SubMenu().printExit();
			}
			}
	}
	else if (infoSnacks == 5) {
		System.out.println("=========================================================================");
		System.out.println("5. Information about Super Ring: ");
		System.out.println("Super Ring are cheap, very cheesy-smelling, cheesy-tasting soft cracker rings.");
		System.out.println("Those not familiar with the snack might be repulsed");
		System.out.println("with the initial cheesy attack but bear with the smell and you'll find a pleasantly sweet,");
		System.out.println("creamy and salty cracker that's both cheap and satisfying at the same time.");
		System.out.println("ORIGIN : Malaysia");
		System.out.println("Stock: " + stocks);
		System.out.println("=========================================================================");
		System.out.println("Do you want know information about another item?");
		System.out.println("(1=yes/0=no)");
		infoSnacks  = input.nextInt();
		if (infoSnacks == 1) {
			new SubMenu().printInformation();
			information = input.nextInt();
		if (information > 5) {
			new SubMenu().printError();
			infoSnacks= input.nextInt();
		}
		else if (infoSnacks == 0) {
			new SubMenu().printExit();
		}
		}
	}
	}
}




:code:

THIS CODE CAN NOT WORK 100%
BUT STILL CAN RUN AND NO ERROR

THANKS

This post has been edited by modi123_1: 06 June 2020 - 06:58 AM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: So i need create like an cashier program using java code

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15724
  • View blog
  • Posts: 62,994
  • Joined: 12-June 08

Re: So i need create like an cashier program using java code

Posted 06 June 2020 - 06:59 AM

Java is not Javascript. Moving to the java forum.

Please explain what isn't working, or how it isn't working.
Was This Post Helpful? 0
  • +
  • -

#3 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: So i need create like an cashier program using java code

Posted 06 June 2020 - 07:07 AM

Note: The printInfo... methods can all be static because they do not require any class field data.
To call use the class name as qualifier: SubMenu.printInfo.... not new SubMenu().printInfo...

Naming conventions say all variable names should start with a lowercase letter.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1