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
Which of the following is a quick way to restore the arrow pointer after you have used it for drawing?
Oxana [17]
A quick way to restore the arrow pointer after you have used it for drawing is to press the esc key.  The esc key is <span>used for any of the different </span>functions<span>, as to interrupt or cancel the current process or running program, or to close a pop-up window.</span>
7 0
2 years ago
What online resource would you use if you wanted to read a review about a new movie?
Vilka [71]

Answer:

fdgf

Explanation:

fdgdfg

5 0
2 years ago
Why is it important to explore an Integrated
dezoksy [38]

Answer:

The answer to this question is given below in the explanation section. The correct answer is B.

Explanation:

The purpose behind to explore an integrated development environment is to learn more about the features of the environment.

So the correct answer is B.

For example, you can use visual studio to build asp.net application using c#, then you need to explore what features visual studio offering to you.

However, other options are incorrect. Because, you can learn more about syntax, error handling, and abstraction in the programming language, not in the IDE.

6 0
2 years ago
If you enter 234.567 into a cell that is formatted to display 1 decimal point place, what is the value stored in the cell
zalisa [80]

IT WILL NOT BE 234.6 FOR PF GANG JUST TOOK THE TEST

6 0
3 years ago
Question 1(Multiple Choice Worth 2 points)<br> Which of the following is true of a good photograph?
Rainbow [258]

Answer:

No link but good things about a photgrahp are

Explanation:

Good lighting

Good camra

Good spot

Good zoom

Good focus

4 0
2 years ago
Read 2 more answers
Other questions:
  • How do you create a reference page in apa format with all websites?
    5·1 answer
  • True or false: when an ospf route sends its link state information, it is sent only to those nodes directly attached neighbors.
    14·1 answer
  • Kyle wants to access his school’s home page. How can he do this?
    8·2 answers
  • How to open a new word proccessing document
    9·1 answer
  • The Internet began when a large company wanted to sell products online. <br> True or flase?
    6·2 answers
  • I need help with this question. its in the photo
    10·1 answer
  • How to convert meters to centimeters in c programming​
    8·1 answer
  • Which Excel function or tool will you use to display the cells that are referred to by a formula in the selected cell
    8·1 answer
  • Difference between hacking and cracking not hackers and crackers ​
    10·1 answer
  • a benefit of cloud computing is scaling up or down as demand for your services increases or decreases. the word that is most ass
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!