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
You work part time at a computer repair store. You are in the process of building a new computer system. The customer wants a mo
kumpel [21]

Answer:

Building of a New Computer System

Explanation:

Specification

a motherboard having dual core 64 bit dual core processor with 8 GB RAM of dual channel memory support with 16x PCI Express slot for video card and firewire support.

8 0
4 years ago
A certain computer can be equipped with 268,435,456 bytes of memory. Why would a manufacturer choose such a peculiar number inst
Arte-miy333 [17]

Answer:

Computer system use Binary and it uses power of 2 only.

Explanation:

The reasons for equipping memory with a peculiar number instead of round or even number are as follows:

  • The computer system uses the power of 2 instead of the power of 10 to equipping memory and hence use a number like 250,000,000 is not possible.
  • The computer systems work on the memory where 1 MB or 1 megabyte shows as 1024 kb or 1,048,576 bytes.
  • In computer system memory capacity is always some multiply of 1024 bytes.
  • Hence, 268,435,456 bytes of memory shows 256 MB of memory.

5 0
4 years ago
A system analyst generally needs to have a number of skills. For example, technical and analytical skills are required for this
polet [3.4K]

Answer: See explanation

Explanation:

Systems analysts are the people who analyse how a particular software, or IT system will be able to fit and meet the needs of their company or client. They are charged with the responsibility of writing requirements for new systems.

Some if the skills required for a system analyst include:

• Flexibility

• Strong analytical skills

• Adaptability

• Initiative

• Interpersonal skills.

• Attention to detail.

• Teamwork skills.

• Written and verbal communication skills.

8 0
3 years ago
The following code segment is a count-controlled loop going from 1 to 5. At each iteration, the loop counter is either printed o
quester [9]

Answer:

True.

Explanation:

For all the count values, if Ranfun() returns true then all the values of count would be printed. Then the sequence of count values printed would be 1 2 3 4 5. Also for all the values of count if Ranfun() returns false then all the values would be enqueued. When we try to dequeue elements from queue we would get them in the same order of their entry into the queue. Thus, the sequence would be 1 2 3 4 5. Hence, we can say that this output sequence is possible. TRUE.

4 0
3 years ago
Randy earn $22 per hour. This is an example of
ra1l [238]

Answer:

I am confused what the question is asking, but I am guessing what $22 per hour means? He earns $22 for every hour he works or does something.

So this hourly wage?  

Wage is the answer you are looking for.

8 0
3 years ago
Other questions:
  • ?trophic levelNYIGVU.;/IO9YK7,'0;
    12·1 answer
  • When a formula contains the address of a cell, it is called a(n)
    9·1 answer
  • What is a collection?
    5·1 answer
  • The integer variables first and last have been declared and assigned values (with last &gt;= first). Allocate an integer array t
    10·1 answer
  • Sam's manager would like him to create and distribute copies of a budget report for each department. The budget report should sh
    10·2 answers
  • What can be done in order to secure a WLAN/wireless access point?
    12·1 answer
  • A researcher wants to do a web-based survey of college students to collect information about their sexual behavior and drug use.
    7·1 answer
  • Documenting Business Requirements helps developers control the scope of the system and prevents users from claiming that the new
    13·1 answer
  • Which scenario could be represented by the given graph?
    14·1 answer
  • What is the default view when you first open a PowerPoint presentation
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!