Assignemnt #103 Keychains Part Three
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Keythree
///File Name: Keythree.java
import java.util.Scanner;
public class Keythree
{
public static void main( String[] args )
{
int choice;
int n=0,a;
do
{
Scanner momo = new Scanner(System.in);
System.out.println("Keychain Shop!");
System.out.println("1. Add Keychains to order");
System.out.println("2. Remove Keychains from order");
System.out.println("3. View current order");
System.out.println("4. Checkout");
System.out.println("5. Leave the page");
choice=momo.nextInt();
if (choice==1)
n=Add(n);
else if (choice==2)
n=Remove(n);
else if (choice==3)
View(n);
else if (choice==4)
Checkout(n);
else
Bye();
} while( choice!=5);
}
public static int Add(int n)
{
int a;
Scanner momo = new Scanner(System.in);
System.out.println( "How many Keychains would you like to add, you currently have " + n + "?");
a=momo.nextInt();
n=n+a;
return n;
}
public static int Remove(int n)
{
int b;
Scanner momo = new Scanner(System.in);
System.out.println( "How many Keychains would you like to remove?");
b=momo.nextInt();
if (n>b)
{
n=n-b;
}
if (n
Picture of Output