Skip to content

Q3 - Bill with GST

Calculate the total bill for three items including 18% GST.

package DSA.Practice_questions.VARIABLES_and_DATA_TYPES_QUESTIONS;
//Question3:Entercostof3itemsfromtheuser(usingfloatdatatype)-apencil,apenandan eraser. You have to output the total cost of the items back to the user as their bill.(Add on : You can also try adding 18% gst tax to the items in the bill as an advanced problem)
import java.util.*;
public class question3 {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
System.out.println("Enter Item numbers");
float a = sc.nextFloat();
float b = sc.nextFloat();
float c = sc.nextFloat();
double gst = (a + b + c) * 0.18;
double bill = a + b + c + gst;
System.out.println("Your GST is " + gst);
System.out.println("Your bill is = " + bill);
} catch (Exception e) {
System.out.println(e);
}
}
}