Advertisement
kamandos

HW3

Jun 29th, 2022
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class StoreReceipt {
  4.     static final double TSHIRT_PRICE = 11.1075;
  5.     static final double CHIPS_PRICE = 12.5215;
  6.     static final double COKE_PRICE = 1.99;
  7.     String a;
  8.     static int numberShirts;
  9.     static int numberChips;
  10.     static int numberCoke;
  11.     static double tshirtTotal = TSHIRT_PRICE * numberShirts;
  12.     static double chipsTotal = CHIPS_PRICE * numberChips;
  13.     static double cokeTotal = (COKE_PRICE + 1.20) * numberCoke;
  14.     static double finalTotal = tshirtTotal + chipsTotal + cokeTotal;
  15.     {
  16.     }  
  17.  
  18.     private static Scanner input;
  19. input = new Scanner(System.in);
  20. System.out.println("What's your name?");
  21. String a = input.nextLine();
  22. System.out.println("Welcome to Fantastiko Market, " + a + "! Heres the following items for saleing:");
  23. System.out.println("T-shirt     $18.95    15% off");
  24. System.out.println("Chips       $1.79     15% off");
  25. System.out.println("Coke        $2.99");
  26. System.out.println("How many T-shirts do you want?");
  27. String numberShirts = input.nextLine();
  28. System.out.println("How many bags of potato chips?");
  29. String numberChips = input.nextLine();
  30. System.out.println("What about 12-pack coke?");
  31. String numberCoke = input.nextLine();
  32.  
  33. double tshirtTotal = TSHIRT_PRICE * numberShirts;
  34. double chipsTotal = CHIPS_PRICE * numberChips;
  35. double cokeTotal = (COKE_PRICE + 1.20) * numberCoke ;
  36. tshirtTotal = tshirtTotal * .85;
  37. chipsTotal  = chipsTotal * .85;
  38. tshirtTotal = tshirtTotal * 1.06;
  39. double finalTotal = tshirtTotal  + chipsTotal  + cokeTotal;
  40. System.out.println("Your total is: " + finalTotal);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement