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]
2 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]2 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
When an interrogator speaks highly about how a crime was committed, hoping to get the suspect to brag about his or her involveme
Alexeev081 [22]

I’d go with b. egotistical, i’m not entirely sure though. It seems like he is trying to appeal to the suspects EGO

8 0
3 years ago
Read 2 more answers
Discovery of a vulnerability in a software program can potentially be sold to the government. Group of answer choices True False
enyata [817]

Discovery of any vulnerability in a software program can potentially be sold to the government: True.

<h3>What is vulnerability?</h3>

Vulnerability is any form of weakness, flaw or defect that is found in a software application, computer system, or network, which can be exploited by an attacker (hacker), in order to gain an unauthorized access and privileges to sensitive user data that are stored in a computer system.

This ultimately implies that, a vulnerability in a software application can potentially be sold to the government, so as to avert and mitigate any form of unauthorized access and privileges to sensitive user data.

Read more on vulnerability here: brainly.com/question/25813524

#SPJ1

4 0
1 year ago
Why is it important to know who reviews the information posted on a Web site?​
Aleks [24]

.bordered {    width: 200px;    height: 100px;    padding: 20px;    border-width: 6px;    border-color: pink;    border-style: dashed solid double;  }Why there is a need of concrete and coherent presentation ? ( class 9 ) {information technology}

5 0
3 years ago
Nicole is in a study group to prepare for a test on plant biology, a subject she knows a lot about. During their meetings, she a
Anestetic [448]

Answer:

b

Explanation:

i pretty sure it b , yep it is b

4 0
2 years ago
Read 2 more answers
Which three options below describe typographic hierarchy?
Korvikt [17]

The three options that describe the typographic hierarchy are given below:

  • The importance of information is shown through the text.
  • The presentation of the text in terms of structure.
  • The placement of the text defines its flow and hierarchy.

Thus, the correct options are A, B, and C.

<h3>What is Typographic hierarchy?</h3>

Typographic hierarchy may be characterized as an approach that utilizes typography: the size, font, and layout of distinct text components to produce a hierarchical division that can authenticate users where to look for specific information.

The purpose of using this methodology is to focus on the main points of the article accordingly. It increases the sense of understanding of the readers with focus.

Therefore, it is well described above.

To learn more about Typographic hierarchy, refer to the link:

brainly.com/question/12076206

#SPJ1

3 0
1 year ago
Other questions:
  • Binary search requires that data to search be in order. true or false
    5·1 answer
  • Jason is computer professional who has access to sensitive information. He shares this information with another organization in
    8·1 answer
  • Fedora operating system
    9·1 answer
  • Write a MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the
    6·1 answer
  • What is blogging
    15·2 answers
  • What power brake uses vacuum from the engine to aid in brake application?
    6·2 answers
  • What is a Slide Master? A. the placeholder used to insert objects B. the sequence of slides in a presentation C. the default des
    14·1 answer
  • Durante 10s, la velocidad de rotación y el momento de giro de las ruedas de un coche eléctrico son 100 rpm y 1405,92 Nm, respect
    15·1 answer
  • Plz hurry it’s timed
    5·1 answer
  • PLEASE HELP THANK YOU
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!