Repository navigation
Expand file tree
/
Copy pathPrintBill.java
More file actions
30 lines (30 loc) · 1.64 KB
/
Copy pathPrintBill.java
File metadata and controls
30 lines (30 loc) · 1.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
package binod;
import java.util.Scanner;
public class PrintBill {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter cost of pencil:");
float costOfPencil = scanner.nextFloat();
System.out.println("Enter cost of pen");
float costOfPen = scanner.nextFloat();
System.out.println("Enter cost of eraser");
float costOfEraser = scanner.nextFloat();
final float taxRate = 0.18f;
float totalCostWithoutTax = costOfPencil + costOfPen + costOfEraser;
float taxForPencil = taxRate * costOfPencil;
float taxForPen = taxRate * costOfPen;
float taxForEraser = taxRate * costOfEraser;
float totalTax = taxForPencil + taxForPen + taxForEraser;
float costOfPencilWithTax = costOfPencil + taxForPencil;
float costOfPenWithTax = costOfPen + taxForPen;
float costOfEraserWithTax = costOfEraser + taxForEraser;
float totalCostWithTax = costOfPencilWithTax + costOfPenWithTax + costOfEraserWithTax;
System.out.println("Item\tCost\tTax\tPrice");
System.out.println("----------------------------------");
System.out.println("Pencil\t" + costOfPencil + "\t" + taxForPencil + "\t" + costOfPencilWithTax);
System.out.println("Pen\t" + costOfPen + "\t" + taxForPen + "\t" + costOfPenWithTax);
System.out.println("Eraser\t" + costOfEraser + "\t" + taxForEraser + "\t" + costOfEraserWithTax);
System.out.println("----------------------------------");
System.out.println("Total\t" + totalCostWithoutTax + "\t" + totalTax + "\t" + totalCostWithTax);
}
}