Write a Java program to sell a limited number of cinema tickets. Each person can buy up to 4 tickets, where the number of available tickets is 100. Your program should do the following: 1. Prompt the user for the number of tickets to buy. Display the number of remaining tickets. 2. Repeat the above steps until all tickets have been sold. Display the total number of buyers. 3. 4. Invalid testing: (1) If the number of tickets to buy is negative or zero, then print an invalid message. (2) If the number of tickets to buy is more than 4, then print a message that the maximum tickets to buy is 4. (3) If the number of tickets to buy is more than the available tickets, then print a message that there are no enough tickets available. See sample input/output on the right side How many tickets do you want to buy? 3 Available tickets = 97 How many tickets do you want to buy? 6 Sorry. Maximum tickets to buy is 4. ***** How many tickets do you want to buy? 4 Available tickets = 2 How many tickets do you want to buy? 3 Sorry. Only 2 tickets are left.] How many tickets do you want to buy? 2 Total number of buyers is 32

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Write a Java program to sell a limited number of cinema tickets. Each person
can buy up to 4 tickets, where the number of available tickets is 100. Your
program should do the following:
1. Prompt the user for the number of tickets to buy.
2.
Display the number of remaining tickets.
3.
Repeat the above steps until all tickets have been sold.
Display the total number of buyers.
4.
Invalid testing: (1) If the number of tickets to buy is negative or zero, then
print an invalid message. (2) If the number of tickets to buy is more than 4,
then print a message that the maximum tickets to buy is 4. (3) If the number
of tickets to buy is more than the available tickets, then print a message that
there are no enough tickets available. See sample input/output on the right side
How many tickets do you want to buy? 3
Available tickets = 97
How many tickets do you want to buy? 6
Sorry. Maximum tickets to buy is 4.
.....
How many tickets do you want to buy? 4
Available tickets = 2
How many tickets do you want to buy? 3
Sorry. Only 2 tickets are left.
How many tickets do you want to buy? 2
Total number of buyers is 32
Transcribed Image Text:Write a Java program to sell a limited number of cinema tickets. Each person can buy up to 4 tickets, where the number of available tickets is 100. Your program should do the following: 1. Prompt the user for the number of tickets to buy. 2. Display the number of remaining tickets. 3. Repeat the above steps until all tickets have been sold. Display the total number of buyers. 4. Invalid testing: (1) If the number of tickets to buy is negative or zero, then print an invalid message. (2) If the number of tickets to buy is more than 4, then print a message that the maximum tickets to buy is 4. (3) If the number of tickets to buy is more than the available tickets, then print a message that there are no enough tickets available. See sample input/output on the right side How many tickets do you want to buy? 3 Available tickets = 97 How many tickets do you want to buy? 6 Sorry. Maximum tickets to buy is 4. ..... How many tickets do you want to buy? 4 Available tickets = 2 How many tickets do you want to buy? 3 Sorry. Only 2 tickets are left. How many tickets do you want to buy? 2 Total number of buyers is 32
Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY