-
Notifications
You must be signed in to change notification settings - Fork 0
/
salesTax.java
42 lines (35 loc) · 1.02 KB
/
salesTax.java
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
//Captain-Price-TF-141
import java.util.Scanner; // Needed for the Scanner class
/**
This program calculates the total price which includes
sales tax.
*/
public class salesTax
{
public static void main(String[] args)
{
// Identifier declarations
final double TAX_RATE = 0.055;
double price;
double tax;
double total;
String item;
// Create a Scanner object to read from the keyboard.
Scanner keyboard = new Scanner(System.in);
// Display prompts and get input.
System.out.print("Item description: ");
item = keyboard.nextLine();
System.out.print("Item price: $");
price = keyboard.nextDouble();
// Perform the calculations.
tax = price * TAX_RATE;
total = price + tax;
// Display the results.
System.out.print(item + " $");
System.out.println(price);
System.out.print("Tax $");
System.out.println(tax);
System.out.print("Total $");
System.out.println(total);
}
}