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
Oduvanchick [21]
3 years ago
5

Write an application to pre-sell a limited number of theatre tickets. Each buyer can buy as many as 6 tickets. No more than 178

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

Answer:

THe required code is given below:

Explanation:

import java.util.Scanner;

public class TicketSeller {

public static int count=0;

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

 

int order; //number of ticket ordered

int numberTickets; //total number of available tickets

System.out.println("Input the number of tickets you want to sell: ");

numberTickets = scanner.nextInt();

//continue until there are no tickets remaining

while (numberTickets>0)

{

System.out.println("\nInput requested tickets: ");

order = scanner.nextInt();

if (order<=numberTickets) //check if the ordered number is less than(or equal to) the available tickets

{

numberTickets= processOrder(order,numberTickets);

count++; //increase the count of number of buyers

}

else System.out.println("Too many tickets requested, please try again.");

}

System.out.println("You have had "+count+ " buyers.");

}

public static int processOrder(int order, int numberTickets){

Scanner scanner = new Scanner(System.in);

if(order>4) //check if order is more than 4

{

System.out.println("Too many tickets requested, please try again.");

System.out.println("\nInput requested tickets: "); //ask to input number of tickets again

order = scanner.nextInt();

numberTickets= processOrder(order,numberTickets);

count++; //increase the count of number of buyers

 

}

else

{

numberTickets=numberTickets-order; //subtract the number of ordered tickets from available tickets

System.out.println("Thank you for your purchase. There are "+numberTickets+ " tickets remaining.\n");

}

 

return numberTickets;

}

You might be interested in
The 3 parts of the CPU are
katrin2010 [14]

Central Processing Unit

Arithmitic Logic Unit

Control Unit


3 0
3 years ago
Read 2 more answers
The transport layer protocol used by the tcp / ip suite that does not provide guarantees on ordering or confirmation of receipt
VARVARA [1.3K]
UDP = connectionless vs. TCP is connection oriented.
4 0
3 years ago
The total number of possible keys for des is _________, which a modern computer system can break in a reasonable amount of time.
FinnZ [79.3K]
The answer is two. Most people think it's one but it's 2
3 0
3 years ago
What is another word for microchips operating systems input methods and everything in between?
lord [1]
The answer is computer. A computer is made up of microchips (CPU and GPU), an operation system (macOS or Windows), input methods (keyboard and mouse), and other parts.
7 0
3 years ago
To close a tab, click the ____ button in the web page thumbnail on the tab switcher.
slavikrds [6]
Tabs are rectangular boxes found on top of your we browser. At the right of each of those tabs, you see a symbol written in 'x' (as shown in the picture). This is the one you should click to close an existing tab.

3 0
3 years ago
Other questions:
  • If your laptop is not able to connect to your wireless network, which of the following might be a likely cause of the problem?
    11·2 answers
  • A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i
    15·2 answers
  • What is a row of data in a database called?<br> Field<br> File<br> Record<br> Title
    10·1 answer
  • Write a function called convert_format which converts the format of a date from mm/dd/yyyy to month name dd, yyyy.
    12·1 answer
  • as the new hr manager hired by a company to clean up some of the company's problems,analyse the system requirements for the comp
    14·1 answer
  • A company purchased a high-quality color laser printer to print color brochures and sales proposals. The printer is connected to
    5·1 answer
  • The function below takes a single argument: data_list, a list containing a mix of strings and numbers. The function tries to use
    6·1 answer
  • Write: In a five-paragraph essay that is two to three pages in length, address the
    13·1 answer
  • How is knowing how to use word or docs importamt?
    8·1 answer
  • What technology would a bank's website use a scramble information as it is transmitted over the Internet
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!