Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SterlingSilver {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scnr = new Scanner(System.in);
  7.         String firstName;
  8.         String lastName;
  9.         String purchaseDate;
  10.         String grouponCode;
  11.         int numberPurchased;
  12.         int ITEMCOST = 35;
  13.         int salesTotal;
  14.  
  15.         System.out.print("Enter the customers first name: ");
  16.         firstName = scnr.next();
  17.  
  18.         System.out.print("Enter the customers last name: ");
  19.         lastName = scnr.next();
  20.  
  21.         System.out.print("Enter the purchase date in the 10 digit format: ");
  22.         purchaseDate = scnr.next();
  23.  
  24.         System.out.print("Enter the amount of items purchased: ");
  25.         numberPurchased = scnr.nextInt();
  26.  
  27.         System.out.print("Enter the groupon code if applicable: ");
  28.         grouponCode = scnr.next();
  29.  
  30.         salesTotal = ITEMCOST * numberPurchased;
  31.  
  32.         if (grouponCode.equals("TwoItems2017")) {
  33.             if (numberPurchased >= 2) {
  34.                 System.out.println ("You have applied the 2 item coupon");
  35.             }
  36.             else {
  37.                 System.out.println ("You do not have the valid amount of items for this purchase");
  38.             }
  39.         }
  40.  
  41.         else if (grouponCode.equals("OneItem2017")) {
  42.             if (numberPurchased >= 1) {
  43.                 System.out.println ("You have applied the 1 item coupon");
  44.             }
  45.             else {
  46.                 System.out.println ("You do not have the valid amount of items for this coupon.");
  47.             }
  48.         }
  49.  
  50.         else {
  51.             System.out.println ("You have not entered a valid coupon");
  52.         }
  53.  
  54.         if (numberPurchased < 0) {
  55.            System.out.println ("The purchase number cannot be negative");
  56.         }
  57.  
  58.         System.out.println("Thank you for purchasing jewelry from Sterling Silver, Inc.");
  59.         System.out.println("\n");
  60.         System.out.println("Name:\t" + firstName + " " + lastName + "\t\tPurchase Date:\t" + (purchaseDate.substring(0, 2)) + "-" + (purchaseDate.substring(2, 4)) + "-" + (purchaseDate.substring(4, 8)));
  61.         System.out.println("Groupon Code: " + grouponCode);
  62.         System.out.println("Number of items purchased: " + numberPurchased);
  63.         System.out.println("Amount due and paid: " + salesTotal);
  64.  
  65.  
  66.  
  67.     }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement