-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathMain.java
More file actions
74 lines (57 loc) · 2.64 KB
/
Main.java
File metadata and controls
74 lines (57 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package org.codedifferently;
import java.util.Scanner;
import static org.codedifferently.randomGenerator.*;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
//Create a scanner for user aka customer inout
Scanner scanner = new Scanner(System.in);
//Ask for customers name
System.out.print("Enter your first name: ");
String name = scanner.nextLine();
//Ask for customers budget
System.out.print("Enter your budget: $");
double budget = scanner.nextDouble();
budget = Math.max(budget, 0);
//Ask for coupon code
System.out.println("Enter a coupon code: ");
String code = scanner.next();
Object receipt;
String[] strings = args;
{
int visitID = randomVisitID();
double price1 = itemPrice(1);
double price2 = itemPrice(2);
double price3 = itemPrice(3);
double tax = taxRate();
double subTotal = subtotal(price1, price2, price3);
double total = subTotal + (subTotal * tax);
System.out.println("-----Welcome to JKB's One stop Shop store-----");
System.out.println(" ");
System.out.println(" ");
System.out.println("Visit ID: " + name + visitID);
System.out.println("Item 1 Price: $" + String.format("%.2f", price1));
System.out.println("Item 2 Price: $" + String.format("%.2f", price2));
System.out.println("Item 3 Price: $" + String.format("%.2f", price3));
System.out.println("Subtotal: $" + String.format("%.2f", subTotal));
System.out.println("Budget: $" + String.format("%.2f", budget));
System.out.println("Final Total: $" + String.format("%.2f", total));
if (total > budget) {
System.out.println("⚠️ Budget exceeded!");
System.out.println("Amount over budget: $" +
String.format("%.2f", total - budget));
} else {
System.out.println("Remaining Balance: $" +
String.format("%.2f", budget - total));
}
System.out.println(" ");
System.out.println("----Thank You for Shopping with Us! ");
System.out.println(" ");
System.out.println("----Checkout our website: JKBsOneStop.com----");
System.out.println(" ");
System.out.println("---Come Again---");
scanner.close();
}
}
}