#Question - make java program based on customers age and time of show and calculate ticket price

4 messages · Page 1 of 1 (latest)

exotic parcel
#

This is my code: ```import java.util.Scanner;
import java.util.*;
class movieticket
{
public static void main(String args[])
{

    int age, T, qtd;
    float total, sum1, sum2, sum3, sum4;
    Scanner scan = new Scanner(System.in);
    System.out.println("Mention your Age and quantity of tickets you want to buy and time using (0/1):  ");
    
    //here, 0 means Day and 1 means night
    
    age = scan.nextInt();
    qtd = scan.nextInt();
    T = scan.nextInt();
    System.out.println("\nDetails: ");
    System.out.println("Your age is " +age);
    System.out.println("Your ticket quantity is " +qtd);
    System.out.println("Selected time is: " +T);
    {

if (age<13 && T==0 )
{
    sum1 = 40 * qtd;
    System.out.println("\nYour age group is child. Below details are your pricing according to Day time:");
    System.out.println("Ticket fare "+sum1);
}
else if(age<13 && T==1)
{
    sum2 = 60 * qtd;
        System.out.println("Your age group is child. Below details are your pricing according to Night time:");
    System.out.println("Ticket fare "+sum2);
}
else if(age>=13 && T==0)
{
    sum3 = 50 * qtd;
    System.out.println("Your age group is an adult. Below details are your pricing according to Day time:");
    System.out.println("Ticket Fare "+sum3);
}
else if(age>=13 && T==1)
{
    sum4 = 100 * qtd;
    System.out.println("Your age group is an adult. Below details are your pricing according to Night time:");
    System.out.println("Ticket Fare "+sum4);
}
else
    System.out.println("your specified time is not 0 or 1 OR Your age is typed wrong. Retry.");

}
}
}```

slow drumBOT
#

This post has been reserved for your question.

Hey @exotic parcel! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

exotic parcel
#

points to mention- i tried this and corrected this but didnt worked.
here, normal and matinee's show ticket price for adults is 100 and 50.
Adults are those over 13 yrs.
For children, ticket price are - 60 and 40. - normal and matinee.

i took 0 as day
and 1 as night.
but i get lots of wrong answers