Movie Ticket Sale Java Application
Submitted by GeePee on Sunday, May 24, 2015 - 22:29.
The following Java application program is a Movie Ticket Sale. This sample designs and implementation a program that prompts the user to input the movie name, adult ticket price, child ticket price, number of child ticket sold, amd percentage of the gross amount to be donated to the charity. . I will be using the JCreator IDE in developing the program.
To start in this tutorial, first open the JCreator IDE, click new and paste the following code.
Sample run:
The following are the algorithm:
1. Get the movie name
2. Get the price of an adult ticket.
3. Get the price of a child ticket.
4. Get the number of adult ticket sold.
5. Get the number of child ticket sold.
6. Get the percentage of the gross amount donated to charity.
7. Calculate the gross amount using the following formula:
- import javax.swing.JOptionPane;
- public class MovieTicket
- {
- {
- String movieName;
- String inputStr;
- String outputStr;
- double adultTicketPrice;
- double childTicketPrice;
- int noOfAdultTicketsSold;
- int noOfChildTicketsSold;
- double percentDonation;
- double amountDonated;
- double netSaleAmount;
- double grossAmount;
- ("Enter the price of an adult ticket: ");
- ("Enter the price of an child ticket: ");
- ("Enter the number of an adult ticket sold : ");
- ("Enter the number of an child ticket sold : ");
- ("Enter the percentage of the donation : ");
- grossAmount = adultTicketPrice * noOfAdultTicketsSold + childTicketPrice * noOfChildTicketsSold;
- amountDonated = grossAmount * percentDonation / 100;
- netSaleAmount = grossAmount - amountDonated;
- outputStr = " Movie Name: " + movieName + "\n"
- + "Number of Ticket Sold: "
- + (noOfAdultTicketsSold + noOfChildTicketsSold) + "\n"
- + " Gross Amount: $"
- + " Percentage of the Gross Amount Donated: "
- + "Amount Donated: $"
- + "Net Sale: $"
- "Theater Sales Data",
- }
- }







grossAmount = adultTicketPrice * noOfAdultTicketsSold + childTicketPrice * noOfChildTicketsSold
8. Calculate the amount donated to charity using the formula:
= grossAmount * percentDonation / 100;
9. Calculate the net sale amount:
netSaleAmount = grossAmount - amountDonated;
Comments
Add new comment
- Add new comment
- 1591 views