Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SAMPLE INPUT/OUTPUT How many tickets do you want to buy? 3 Available tickets - 97 How many tickets do you want to buy? 6 Sorry.

image text in transcribed
SAMPLE INPUT/OUTPUT 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. 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. 4. Display the total number of buyers. 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? 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 tablet 109 Smout prindhow many tiets do you want to buy Lost saved 2.50-ZAM Submit SIL Prt Sen. Home End Poup

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books