Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Need help finishing Million $ program

    hey, i'm working on a program that deals with gross income and other situations. what i need to add is how many days it will take for the gross income to meet a million dollars. if you read the code well enough you'll see a section that states "number of days till you meet 1 million" this is where im hitting a wall.. THANKS!

    here's whats going on so far...

    Code:
    import javax.swing.JOptionPane;
    
    public class MovieTicketSale
    {
    	public static void main (String[] args)
    	{
    		String movieName;
    		String inputStr;
    		String outputStr;
    		
    		double adultTicketPrice;
    		double childTicketPrice;
    		
    		int noOfAdultTicketsSold;
    		int noOfChildTicketsSold;
    		int milli = 1000000;
    		
    		double percentDonation;
    		double grossAmount;
    		double amountDonated;
    		double netSaleAmount;
    		double Milli;
    		
    		movieName = JOptionPane.showInputDialog
    						("Enter the movie name");
    						
    		inputStr = JOptionPane.showInputDialog
    						("Enter the price of an adult ticket");
    		adultTicketPrice = Double.parseDouble(inputStr);
    		
    		inputStr = JOptionPane.showInputDialog
    						("Enter the price of a child ticket");
    		childTicketPrice = Double.parseDouble(inputStr);
    		
    		inputStr = JOptionPane.showInputDialog
    						("Enter the number of adult tickets sold");
    		noOfAdultTicketsSold = Integer.parseInt(inputStr);
    		
    		inputStr = JOptionPane.showInputDialog
    						("Enter the number of child tickets sold");
    		noOfChildTicketsSold = Integer.parseInt(inputStr);			
    		
    		inputStr = JOptionPane.showInputDialog
    						("Enter the percentage of the donation");
    		percentDonation = Double.parseDouble(inputStr);		
    		
    		grossAmount = 	adultTicketPrice * noOfAdultTicketsSold + childTicketPrice * noOfChildTicketsSold;
    		
    		amountDonated = grossAmount * percentDonation / 100;
    		netSaleAmount = grossAmount - amountDonated;
    		
    		
    		
    		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)
    					+ "Number of days to make a 1 Million: " ;
    					
    		JOptionPane.showMessageDialog(null, outputStr, "Theater Sales Data", JOptionPane.INFORMATION_MESSAGE);
    		System.exit(0);
    	}
    }

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,306
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!



    It is your responsibility to die() if necessary….. - PHP Manual

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Location
    Toronto, ON
    Posts
    102
    Thanks
    12
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Philip M View Post
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!



    It is your responsibility to die() if necessary….. - PHP Manual
    lol

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,603
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    But in any case, the answer is simple arithmetic.

    The number of days needed will obviously be 1000000000 divided by the gross amount per day.

    If you can do the other math, why can't you do a simple divide?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •