Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SterlingSilver {
- public static void main(String[] args) {
- Scanner scnr = new Scanner(System.in);
- String firstName;
- String lastName;
- String purchaseDate;
- String grouponCode;
- int numberPurchased;
- int ITEMCOST = 35;
- int salesTotal;
- System.out.print("Enter the customers first name: ");
- firstName = scnr.next();
- System.out.print("Enter the customers last name: ");
- lastName = scnr.next();
- System.out.print("Enter the purchase date in the 10 digit format: ");
- purchaseDate = scnr.next();
- System.out.print("Enter the amount of items purchased: ");
- numberPurchased = scnr.nextInt();
- System.out.print("Enter the groupon code if applicable: ");
- grouponCode = scnr.next();
- salesTotal = ITEMCOST * numberPurchased;
- if (grouponCode.equals("TwoItems2017")) {
- if (numberPurchased >= 2) {
- System.out.println ("You have applied the 2 item coupon");
- }
- else {
- System.out.println ("You do not have the valid amount of items for this purchase");
- }
- }
- else if (grouponCode.equals("OneItem2017")) {
- if (numberPurchased >= 1) {
- System.out.println ("You have applied the 1 item coupon");
- }
- else {
- System.out.println ("You do not have the valid amount of items for this coupon.");
- }
- }
- else {
- System.out.println ("You have not entered a valid coupon");
- }
- if (numberPurchased < 0) {
- System.out.println ("The purchase number cannot be negative");
- }
- System.out.println("Thank you for purchasing jewelry from Sterling Silver, Inc.");
- System.out.println("\n");
- System.out.println("Name:\t" + firstName + " " + lastName + "\t\tPurchase Date:\t" + (purchaseDate.substring(0, 2)) + "-" + (purchaseDate.substring(2, 4)) + "-" + (purchaseDate.substring(4, 8)));
- System.out.println("Groupon Code: " + grouponCode);
- System.out.println("Number of items purchased: " + numberPurchased);
- System.out.println("Amount due and paid: " + salesTotal);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement