...

View Full Version : Need help finishing Million $ program



CaseyJames22
02-14-2012, 07:56 PM
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...



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);
}
}

Philip M
02-14-2012, 08:03 PM
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

inchecksolution
02-14-2012, 08:12 PM
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:thumbsup:

Old Pedant
02-14-2012, 09:42 PM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum