Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-14-2012, 07:56 PM   PM User | #1
CaseyJames22
New to the CF scene

 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
CaseyJames22 is an unknown quantity at this point
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);
	}
}
CaseyJames22 is offline   Reply With Quote
Old 02-14-2012, 08:03 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,044
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Old 02-14-2012, 08:12 PM   PM User | #3
inchecksolution
Regular Coder

 
Join Date: Jul 2011
Location: Toronto, ON
Posts: 102
Thanks: 12
Thanked 1 Time in 1 Post
inchecksolution is an unknown quantity at this point
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
inchecksolution is offline   Reply With Quote
Old 02-14-2012, 09:42 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,249
Thanks: 59
Thanked 3,999 Times in 3,968 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
code, java, million

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:46 AM.


Advertisement
Log in to turn off these ads.