Java Reference
In-Depth Information
inputStr = JOptionPane.showInputDialog
("Enter the number of adult tickets sold"); //Step 7
noOfAdultTicketsSold = Integer.parseInt(inputStr);
//Step 8
inputStr = JOptionPane.showInputDialog
("Enter the number of child tickets sold");
//Step 9
noOfChildTicketsSold = Integer.parseInt(inputStr);
//Step 10
inputStr = JOptionPane.showInputDialog
("Enter the percentage of the donation");
//Step 11
percentDonation = Double.parseDouble(inputStr);
//Step 12
grossAmount = adultTicketPrice * noOfAdultTicketsSold +
childTicketPrice * noOfChildTicketsSold;
//Step 13
amountDonated = grossAmount * percentDonation / 100; //Step 14
netSaleAmount = grossAmount - amountDonated;
//Step 15
outputStr = "Movie Name: " + movieName + "\n"
+ "Number of Tickets Sold: "
+ (noOfAdultTicketsSold +
noOfChildTicketsSold) + "\n"
+ "Gross Amount: $"
+ String.format("%.2f", grossAmount) + "\n"
+ "Percentage of the Gross Amount Donated: "
+ String.format("%.2f%%", percentDonation) + "\n"
+ "Amount Donated: $"
+ String.format("%.2f", amountDonated) + "\n"
+ "Net Sale: $"
+ String.format("%.2f", netSaleAmount);
//Step 16
JOptionPane.showMessageDialog( null , outputStr,
"Theater Sales Data",
JOptionPane.INFORMATION_MESSAGE); //Step 17
System.exit(0);
//Step 18
}
}
 
Search WWH ::




Custom Search