1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
STALIN [3.7K]
3 years ago
8

write an application to presell a limited number of cinema tickets. each buyer can buy as many as 4 tickets. No more than 100 ti

ckets can be sold. Implement a program called TicketSeller that prompts the user for the desired number of tickets and then displays the number of remaining ticket. Repeat until all tickets have been sold, and then display the total number of buyers
Computers and Technology
1 answer:
Rus_ich [418]3 years ago
8 0

Answer:

The program for this question can be given as:

Program:

import java.util.*;  //import package

public class TicketSeller  //define class

{

public static void main(String ar[])  //main method

{

int totalTickets=100,userCount=0,remainingTickets=100,numTickets; // varaibale

try           //try block

{

Scanner ob= new Scanner(System.in);  //input by user

System.out.println("Total Tickets:"+totalTickets);

while(remainingTickets!=0)          //loop

{

System.out.print("Enter no of Tickets to buy:");      //message.

numTickets=ob.nextInt(); //taking input

if(numTickets<=4)         //conditional statements.

{

if(remainingTickets>=numTickets)

{

remainingTickets=remainingTickets-numTickets;              //calculate remainingTickets

userCount++;

System.out.println("remaining tickets : "+remainingTickets+" user :"+userCount);      

}

else

{

System.out.println("Invalid Input");

}

}

else

{

System.out.println("Invalid Input");

}

}

}

catch(Exception e)            //catch block.

{

}

}

}

Output:

Total tickets:100

Enter no of Tickets to buy: 4

Remaining tickets : 96 User :1

Enter no of Tickets to buy: 4

Remaining tickets : 92 User :2

Enter no of Tickets to buy: 4

Remaining tickets : 88 User :3

.

.

.

Enter no of Tickets to buy: 4

Remaining tickets : 0 User :25

Explanation:

In the above Program firstly we import the package for the user input. Then we declare the class that is (TicketSeller) given in question. In this class we declare the main method in the main method we declare the variable that is totalTickets, userCount, remainingTickets and numTickets .Then we use the exception handling. we use this for providing the validation from the user side that users don't insert value less the 4. In the exception handling, we use the multiple catch block with try block. Then we input from the user and calculate the values and in the last, we print all the values.

You might be interested in
Discussion Topic
BabaBlast [244]

Answer:

Social media positively affects and impacts the process of globalization. ... Global communities is a social infrastructure tool and as social media helps in strengthening social relationships and bringing people and communities together it leads to creating a string global community.

7 0
3 years ago
Pls I need a reply ASAP
GrogVix [38]

Answer: delete the application and install it again thats what worked for me.

Explanation:

6 0
3 years ago
When a percentage of the smallest and largest values are deleted from a data set, the mean of the remaining data values is the a
xz_007 [3.2K]

Answer:

Correct option C

Trimmed mean

Explanation:

A trimmed mean is a method of averaging that removes a small designated percentage of the largest and smallest values before calculating the mean.

Trimmed mean helps eliminate the influence of data points on the tails that may unfairly affect the traditional mean.

Trimmed means are used in reporting economic data in order to smooth the results and paint a more realistic picture.

5 0
3 years ago
How does an author use artifacts in literature?
cestrela7 [59]
They use artifacts in l<span>iterature in order to develop the plot and the characters.</span>
7 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
Serggg [28]

Answer:

Consistency

Explanation:

Making a website consistent helps people understand the goal and functions of a website, while also keeping the design the same the whole way through.

3 0
3 years ago
Read 2 more answers
Other questions:
  • What is the one common feature that ties together different social media technologies? All of the social media tools we use toda
    5·2 answers
  • Explain the difference between general-purpose and specialized applications. Also discuss the common features of application pro
    11·1 answer
  • Press the _______ key to move to the next cell in a row.
    12·2 answers
  • What did basic elements of music look like in the Twentieth Century period?
    6·1 answer
  • What is the standard internet protocol, which provides the technical foundation for the public internet?
    9·1 answer
  • A digital designer might do computer animation or video games true or false
    13·2 answers
  • What are the peripherals of a computer ​
    12·1 answer
  • How would you delete a slide from your presentation after selecting it?
    14·1 answer
  • What does a theme contain?
    14·2 answers
  • Answer the following question in 3-4 complete sentences. Define the following terms: - registration - press - keyblock.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!