ok, since i left off on number 3, i'll finish what i see on the others
another thing in number 3:
java
if(a=85||105)
System.out.println();
if statements cannot be done in the manner you have it. The way you are doing this is you are attempting to set a to 85
java
if (a==85 || a==105)
{
Sytem.out.println();
}
notice the double equal signs. That means that if a is equal to either 85 or 105 then do the following statement.
starting with number 4:
java
Scanner keyboard = new Scanner(System.in);//Added this statement.
money = keyboard.nextDouble();//Added this statement.
day = keyboard.nextInt();//Added this statement.
System.out.println("Enter the total penny you have.");//Added this statement.
ok, you have your statements out of order. You want to prompt the user before asking them to input. Plus you want to ask them how many days since that is the input, not the number of pennies. Your starting out with one so that is known.
here is a good way of doing this code:
java
int day;
double money = 1.0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter number of days to double penny for:")'
day = keyboard.nextInt();
java
int count = 0;
while(day >= 30);
{
day = 30;
money = penny;
penny = keyboard.nextDouble();
money = 2 * money;
System.out.println("After day " + day +
" you have " + money);
ok your while loop structure is good but incorrect for the instance at hand.
basically your while loop says to do the follow if day is greater than or equal to 30. your loop with always be greater than or equal to 30 since you set day to 30 in the while loop.
try it this way:
java
int currentday = 1;
do
{
money *= 2;
System.out.println("After day: " + currentday + " you have: " + money + " pennies");
currentday++
}while(currentday <= day);
ok number 5:
java
int price = 100;
double price2 = 100.00;
tenPercentOff(price);
tenPercentOff(price2);
you are declaring int price and double price. You only need one of those. I would use a system.in scanner so the user can input the price themselves.
java
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter normal purchase price: ");
double price = keyboard.NextDouble();//not sure on the method but i think its right
tenPercentOff(price);
now, lets look at your function tenPercentOff
java
public static void tenPercentOff(int p)
{
double newPrice = p * .10;
System.out.println("Ten percent off");
System.out.println("New price is " + newPrice);
alright good declaration, however your parameter is wrong. You are sending this function type double but wanting a type int. declare it like so:
java
public static void tenPercentOff(double p)
now lets look at the innards of that function. You do double newPrice = p *.10 what that does is get the sum of 10% of p. What you want is the price after that discount is removed.
java
double newPrice = p - (p*.10);
System.out.println("Ten percent off");
System.out.println("New price is: " + newPrice);
now you just need to finish the ending brackets and that one is good.
now lets look at number 6:
i'll have to get back to you on that one. The way you are doing it is asking for a string or char input and trying to place it into an int variable. That will never work.
This post has been edited by rgfirefly24: 25 Jun, 2008 - 05:51 PM