Assignemnt #102
Code
//colin hinton
//5th period
//Keychain.java
//2/18/2016
import java.util.Scanner;
public class Keychain
{
public static void main (String [] args)
{
System.out.println("Welcome to me shop");
Scanner kb = new Scanner(System.in);
int bulk = 0;
int option;
do
{
System.out.println("1) Add keychains to order");
System.out.println("2) Remove keychains to order");
System.out.println("3) View current order");
System.out.println("4) Checkout");
System.out.print("Please enter a choice ");
option = kb.nextInt();
if (option == 1)
{
bulk = Add(bulk);
}
else if (option == 2)
{
bulk = Remove(bulk);
}
else if (option == 3)
{
View(bulk);
}
else if (option == 4)
{
End(bulk);
}
}while (option != 4);
}
public static int Add(int bulkOne)
{
Scanner kb = new Scanner(System.in);
System.out.println();
System.out.print("You have " + bulkOne + " keychains, how many would you like to add ");
int addition;
addition = kb.nextInt();
int bulk = addition + bulkOne;
System.out.println("You now have " + bulk + " keychains");
return bulk;
}
public static int Remove(int bulkTwo)
{
Scanner kb = new Scanner(System.in);
System.out.println();
System.out.print("You have " + bulkTwo + " keychains, how many would you like to remove ");
int subtract;
subtract = kb.nextInt();
int bulk = bulkTwo - subtract;
System.out.println("You now have " + bulk + " keys");
return bulk;
}
public static void View(int bulkThree)
{
System.out.println();
System.out.println("You have " + bulkThree + " keychains");
System.out.println("Keychains cost $10 dollars each");
System.out.println("Total cost is " + (10*bulkThree));
}
public static void End(int bulkFour)
{
Scanner kb = new Scanner(System.in);
System.out.println();
System.out.print("What is your name? ");
String name;
name = kb.next();
System.out.println("You have " + bulkFour + " keychains");
System.out.println("Keychains cost $10 dollars each");
System.out.println("Total cost is " + (10*bulkFour));
System.out.println("Thanks for your order, " + name);
}
}
Picture of the output