Skip to content

Instantly share code, notes, and snippets.

@Cam1337
Created April 27, 2010 01:50
Show Gist options
  • Save Cam1337/380214 to your computer and use it in GitHub Desktop.
Save Cam1337/380214 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class store {
/*
* This is cameron's store.
*/
static String[] shoppingcart = new String[7];
static double purse=75000.00;
public static void main(String[] args) {
int pointer=0;
boolean inMmenu=true;
while(inMmenu==true){
Scanner thestore = new Scanner(System.in);
entermsg();
int userchoice=thestore.nextInt();
if(userchoice==1){
boolean inPmenu=true;
while(inPmenu==true){
purchasemenu();
int choice=thestore.nextInt();
if(choice==1){
System.out.println("Thanks for buying!");
shoppingcart[pointer] = "car";
purse=purse-45000;
printcart();
pointer=pointer+1;
}
if(choice==2){
System.out.println("Thanks for buying!");
shoppingcart[pointer] = "Soda pop";
purse=purse-2.50;
printcart();
pointer=pointer+1;
}
if(choice==3){
System.out.println("Thanks for buying!");
shoppingcart[pointer] = "Best Friends";
purse=purse-2500;
printcart();
pointer=pointer+1;
}
if(choice==4){
inPmenu=false;
}
}
}
if(userchoice==2){
boolean inSmenu=true;
while(inSmenu==true){
sellmenu();
int choice2=thestore.nextInt();
if(choice2==1){
System.out.println("Thanks for selling");
purse=purse+150;
printcart();
}
if(choice2==2){
System.out.println("Thanks for selling");
purse=purse+2500;
printcart();
}
if(choice2==3){
System.out.println("Thanks for selling");
purse=purse+50000;
printcart();
}
if(choice2==4){
inSmenu=false;
}
}
}
if(userchoice==3){
leavemsg();
inMmenu=false;
}
}
}
public static void purchasemenu()
{
System.out.println("Purchase menu:");
System.out.println("1. Cars");
System.out.println("2. Soda pop");
System.out.println("3. Best friends");
System.out.println("4. Return to main menu");
}
public static void sellmenu()
{
System.out.println("Sell menu:");
System.out.println("1. Farm items");
System.out.println("2. Computers");
System.out.println("3. Illegal items");
System.out.println("4. Return to main menu");
}
public static void leavemsg()
{
System.out.println("Thanks you for coming to the store. Have a nice day!");
}
public static void entermsg()
{
System.out.println("Welcome to the store.");
System.out.println("1. Buy");
System.out.println("2. Sell");
System.out.println("3. Leave");
}
public static void printcart(){
System.out.println("Shopping cart:");
for(int i=0; i<shoppingcart.length;i++){
System.out.println(shoppingcart[i]);
}
System.out.println("You have: $" + purse);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment