Java

Here I’ll put some of my java projects.

Code for Store Project:

import java.util.Scanner;

public class store
{
public static void main(String[] args)
{

Scanner userinput = new Scanner(System.in);
double tax = 0.0;
String amount;
int amt = 0;
double totalCost = 0.0;
double taxrate = 0.05999;
double taxs;
String consumerName;
String order;
String order2=”yes”;
double cost = 0.0;

System.out.println(“Welcome to ChinaPenn!”);
System.out.println(“our restaurant mainly selling Chinese food. please ask waittresses or waitnesses for additional information!”);
System.out.println(“————————————-“);

//consumer name
System.out.println(“Please start your ordering with your name:”);
consumerName = userinput.next();
System.out.println(“————————————-“);

//order
System.out.println(“Dear ” + consumerName);
System.out.println(“we have these choices for you:”);

System.out.println(“soups:”);
System.out.println(“1.Wonton Soup: $2.00”);
System.out.println(“2.Egg Drop Soup: $1.25”);
System.out.println(“3.Chicken Rice Soup: $1.50”);
System.out.println(“4.Seefood Tam Yum Soup: $3.75”);

System.out.println(“Appetizes:”);
System.out.println(“5.Steamed Dumplings: $5.75”);
System.out.println(“6.Crab Rangoon: $5.00”);

System.out.println(“Been Curd:”);
System.out.println(“7.General Tso’s Been(spicy): $5.25”);
System.out.println(“8.Been Curd Home Style: $5.00”);

System.out.println(“————————————-“);
while (order2.equals(“yes”))
{
//user input
System.out.println(“Please enter the number of which one you want to order:”);
order = userinput.next();

if (order.equals(“1”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 2.00;
totalCost = totalCost + tax(totalCost, taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product1=”Wonton Soup”;
int num1 = 0;
num1 = amt;
String result1 = product1 + Integer.toString(num1);
result1 = end(product1,num1);
System.out.println(result1);

}

if (order.equals(“2”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 1.25;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product2 = “Egg Drop Soup”;
int num2 = 0;
num2 = amt;
String result2 = product2 + Integer.toString(num2);
result2 = end(product2,num2);
System.out.println(result2);

}

if (order.equals(“3”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 1.50;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product3 = “Chicken Rice Soup”;
int num3 = 0;
num3 = amt;
String result3 = product3 + Integer.toString(num3);
result3 = end(product3,num3);
System.out.println(result3);

}

if (order.equals(“4”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 3.75;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product4 = “Seefood Tam Yum Soup”;
int num4 = 0;
num4 = amt;
String result4 = product4 + Integer.toString(num4);
result4 = end(product4,num4);
System.out.println(result4);

}

if (order.equals(“5”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 5.75;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product5 = “Steamed Dumplings”;
int num5 = 0;
num5 = amt;
String result5 = product5 + Integer.toString(num5);
result5 = end(product5,num5);
System.out.println(result5);

}

if (order.equals(“6”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 5.00;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product6 = “Crab Rangoon”;
int num6 = 0;
num6 = amt;
String result6 = product6 + Integer.toString(num6);
result6 = end(product6,num6);
System.out.println(result6);

}

if (order.equals(“7”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 5.25;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product7 = “General Tso’s Been(spicy)”;
int num7 = 0;
num7 = amt;
String result7 = product7 + Integer.toString(num7);
result7 = end(product7,num7);
System.out.println(result7);

}

if (order.equals(“8”))
{
System.out.println(“please enter the number you want”);
amount = userinput.next();
amt = Integer.parseInt(amount);
totalCost=totalCost + amt * 5.00;
totalCost = totalCost + tax(totalCost,taxrate);
System.out.println(“anything else?(please type ‘yes’ or ‘no’)”);
order2 = userinput.next();
String product8 = “Been Curd Home Style”;
int num8 = 0;
num8 = amt;
String result8 = product8 + Integer.toString(num8);
result8 = end(product8,num8);
System.out.println(result8);

}
totalCost = Math.round(totalCost * 100.0)/100.0;
cost = cost + totalCost;

}
System.out.println(“————————————-“);
cost = Math.round(totalCost * 100.0)/100.0;
System.out.println(“The final cost is: $” + cost);
System.out.println(“Thank you for parchasing!”);
System.out.println(“See you next time!”);
System.out.println(“China Penn Resaurant”);
System.out.println(“tel: +1(610)-574-623”);
System.out.println(“Web: Chinapenn.com”);
}
public static String end(String product, int num)
{
return product + Integer.toString(num);
}
public static double tax(double totalCost, double taxrate)
{
return totalCost * taxrate;

}
}