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
How to transfer bookmarks to new computer
Romashka-Z-Leto [24]

Explanation:

On your computer, open Chrome

.At the top right, click More

.Select Bookmarks Import Bookmarks and Settings

.Select the program that contains the bookmarks you'd like to import.Click Import.

Click Done

3 0
3 years ago
Draw a flowchart to find the average grade in 3 subjects
mezya [45]

Answer:

See attachment for flowchart

Explanation:

The flowchart is as follows:

Step1: Start

This begins the flowchart

Step 2: Input Score1, Score2, Score3

This gets user input for the three subjects

Step 3: Average = (Score1 + Score2 + Score3)/3

This calculates the average of the three subjects

Step 4: Print Average

This displays the calculated average

Step 5: Stop

This signals the end of the flowchart

4 0
3 years ago
What is LINUX?
valkas [14]

Answer:

The answer is A

Explanation:

I know what it is.

4 0
2 years ago
Read 2 more answers
Why should spain go to Africa ​
uysha [10]

Answer:

to learn about their cultural heritage and historical significance

3 0
3 years ago
After you have created at least four slides, a scroll bar containing scroll arrows and scroll boxes will appear on the right edg
neonofarm [45]

Answer:

I THINK THE ANSWER IS ''TRUE''

Explanation:

6 0
3 years ago
Other questions:
  • What is an (CR) Optical character recognition?
    13·2 answers
  • when seeking information on the on the internet about a variety of subjects the most useful place to look would be?
    13·1 answer
  • What’s the answer to this question?
    15·1 answer
  • Can you get financial aid with average grades
    15·1 answer
  • ____________________ is the primary code humans use to communicate. (Points : 1
    9·1 answer
  • How can we display outputs of DIR one screenful at a time? There are at least two different ways, and either one is acceptable.
    8·1 answer
  • How do I delete my brainly account?<br> I don't need anymore.
    13·2 answers
  • Your customer said that understanding the directions is difficult. This is an aspect of
    6·1 answer
  • Explain why you would use the soft on/off jumper when working on ATX system
    14·1 answer
  • write a function named get majority last name that accepts as its parameter a dictionary from strings to strings the keys of the
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!