mercredi 23 septembre 2020

How can get ticket price constant

If the customer pays less than the ticket price, I want to print the money less than the ticket price and print the rest to pay, or if the customer pays more than the ticket price, the rest of the money is printed to the customer, and finally if he pays the ticket amount, you print welcome

import java.util.Scanner;

public class test {


static Scanner input = new Scanner(System.in);

static int age;

static double ticketprice;

static double tax;

public static void main(String[]args) {


System.out.println("Age");

int age = input.nextInt();

if (age < 12) {

    ticketprice = 10;

    tax = ticketprice * 15 / 100;

    System.out.println("ticket price is ");

    System.out.println(ticketprice + tax);

} else if (age > 60 && age < 110) {
    
    ticketprice = 15;

    tax = ticketprice * 15 / 100;

    System.out.println("your ticket price is ");

    System.out.println(ticketprice + tax);

} else if (age >= 12 && age < 60) {

    System.out.println("Enter (1) if you student or (2) if you not student");
    int study = input.nextInt();

    switch (study) {
    case 1:
        ticketprice = 30;
        tax = ticketprice * 15 / 100;

        System.out.println(" your ticket price 26.5 $ + tax\t" + tax);

        System.out.println("you got off 25% your ticket price now is");

        System.out.println(ticketprice - tax);

        break;
    case 2:

        ticketprice = 30.5;
        tax = ticketprice * 15 / 100;

        System.out.println(" your ticket price is ");

        System.out.println("your ticket price is");

        System.out.println(ticketprice + tax);  
    }
}
System.out.println("Please pay your ticket");


input.nextDouble();


  }
}

Aucun commentaire:

Enregistrer un commentaire