Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Grocery2
- {
- public static void main(String[] args)
- {
- //Setup
- double Total, grocprice1 = 0, grocprice2 = 0, grocprice3 = 0; // Totals
- double prcApple = .30;
- double prcOrange = .45;
- double prcStrawberry = 2.30;
- double prcPotato = 3.25;
- double prcTurnips = .70;
- double prcCarrots = 1.25;
- Scanner scanner = new Scanner(System.in);
- //Screen Input
- //Enter Name
- System.out.println("Enter your full name:");
- String fullname = scanner.nextLine();
- //Enter Address
- System.out.println("Enter your Address");
- String address = scanner.nextLine();
- //Enter Credit Card Number
- System.out.println("Enter your Credit Card Number");
- String creditcard = scanner.nextLine();
- //Enter Date Of Birth
- System.out.println("Enter your Date of Birth");
- String dob = scanner.nextLine();
- //Enter Email Address
- System.out.println("Enter your Email Address");
- String emailaddr = scanner.nextLine();
- //Re-Enter Email Address
- System.out.println("Re-Enter your Email Address");
- String emailaddr2 = scanner.nextLine();
- //Enter First Grocery Item
- System.out.println("Enter the first grocery item ");
- String grc1 = scanner.nextLine();
- //Enter first quantity
- System.out.println("How many of these would you like");
- int qty1 = Integer.valueOf(scanner.nextLine());
- if(grc1.equals("Apples"))
- {
- grocprice1 = prcApple * qty1;
- }
- else if(grc1.equals("Oranges"))
- {
- grocprice1 = prcOrange * qty1;
- }
- else if (grc1.equals("strawberries"))
- {
- grocprice1 = prcStrawberry * qty1;
- }
- else if (grc1.equals("Potatoes"))
- {
- grocprice1 = prcPotato * qty1;
- }
- else if (grc1.equals("Turnips"))
- {
- grocprice1 = prcTurnips * qty1;
- }
- else if (grc1.equals("Carrots"))
- {
- grocprice1 = prcCarrots * qty1;
- }
- //Enter second Grocery Item
- System.out.println("Enter the second grocery item ");
- String grc2 = scanner.nextLine();
- //Enter second quantity
- System.out.println("How many of these would you like");
- int qty2 = Integer.valueOf(scanner.nextLine());
- if (grc2.equals("Apples"))
- {
- grocprice2 = prcApple * qty2;
- }
- else if (grc2.equals("Oranges"))
- {
- grocprice2 = prcOrange * qty2;
- }
- else if (grc2.equals("strawberries"))
- {
- grocprice2 = prcStrawberry * qty2;
- }
- else if (grc2.equals("Potatoes"))
- {
- grocprice2 = prcPotato * qty2;
- }
- else if (grc2.equals("Turnips"))
- {
- grocprice2 = prcTurnips * qty2;
- }
- else if (grc2.equals("Carrots"))
- {
- grocprice2 = prcCarrots * qty2;
- }
- //Enter third Grocery Item
- System.out.println("Enter the third grocery item ");
- String grc3 = scanner.nextLine();
- //Enter third quantity
- System.out.println("How many of these would you like");
- int qty3 = Integer.valueOf(scanner.nextLine());
- if (grc3.equals("Apples"))
- {
- grocprice3 = .60 * qty3;
- }
- else if (grc3.equals("Oranges"))
- {
- grocprice3 = prcOrange * qty3;
- }
- else if (grc3.equals("strawberries"))
- {
- grocprice3 = prcStrawberry * qty3;
- }
- else if (grc3.equals("Potatoes"))
- {
- grocprice3 = prcPotato * qty3;
- }
- else if (grc3.equals("Turnips"))
- {
- grocprice3 = prcTurnips * qty3;
- }
- else if (grc3.equals("Carrots"))
- {
- grocprice3 = prcCarrots * qty3;
- }
- /* Calculate the price */
- Total = grocprice1 + grocprice2 + grocprice3;
- System.out.println("Thank You "+ Total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment