Hi, I was assigned by my teacher to create a simple calculation program about movie tickets that are sold in a local movie theater. So, I created the coding, and it turned out perfect. Here it is:

``````import java.util.Scanner;

public class MovieTheater
{
public static void main(String[] args)
{

String movieName;

Scanner keyboard = new Scanner(System.in);
System.out.println(" Enter the Movie Title: ");
movieName = keyboard.nextLine();
System.out.println(" Adult ticket price per person: ");
System.out.println(" Child ticket price per person: ");
childPrice = keyboard.nextDouble();
System.out.println(" Number of adult tickets sold: ");
System.out.println(" Number of child tickets sold: ");
childNumber = keyboard.nextInt();
System.out.println(" Percentage of gross amount to be donated: ");
percentageDonation = keyboard.nextDouble();

totalChildPrice = childPrice * childNumber;
amountDonated = (percentageDonation/100) * grossAmount;
netSale = grossAmount - amountDonated;

System.out.println(" Movie Name: " + movieName);
System.out.println(" Number of tickets sold: " + totalTickets);
System.out.println(" Gross Amount: " + " \$ " + grossAmount);
System.out.println(" Percentage of the gross amount to be donated: " + percentageDonation);
System.out.println(" Amount Donated: " + " \$ " + amountDonated);
System.out.println(" Net Sale: " + " \$ " + netSale);
}
}
``````

BUT, the outputs "Gross Amount", "Percentage", "Amount Donated" and "Net Sale" are not in the same decimal places as you can see in the output I got here:

`````` Enter the Movie Title:
Anastasia
10.50
Child ticket price per person:
5.50
42
Number of child tickets sold:
70
Percentage of gross amount to be donated:
20
Movie Name: Anastasia
Number of tickets sold: 112
Gross Amount:  \$ 826.0
Percentage of the gross amount to be donated: 20.0
Amount Donated:  \$ 165.20000000000002
Net Sale:  \$ 660.8
``````

I WANT THEM TO BE IN TWO DECIMAL PLACES ONLY. can someone help show me where to add/correct? Thanks in advance!

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by UNDER-18 FG

Alright, got it now. Thanks!