# my High profitable items: 0 Bonus : \$0.00 why??

• March 2nd, 2011, 04:58 PM
chonch
my High profitable items: 0 Bonus : \$0.00 why??
i have this much but i dont get why my high profitable items is 0 and bonus is 0...should be 1 and 20

Code Java:

```import java.util.Scanner;// program uses class Scanner   public class Assign4 { public static void main(String[] args) { new Assign4 (); Scanner input = new Scanner( System.in );   double total; // sum of values double Commission=0; // Commission earned double earnings=0;// number with decimal point for average double bonus=0;// bonus amount for high value items   total = 0; // initialize total int valueCounter = 0; // initialize loop counter   bonus = 0; // initialize bonus int bonusCounter = 0; //initialize bonus counter   System.out.print( "Enter item Value, or -1 to quit: " ); double value = input.nextDouble();   // loop until sentinel value read from user while ( value != -1 ) { total = total + value; // add value to total valueCounter = valueCounter + 1; // increment counter   // prompt for input and read next value from user System.out.print( "Enter item Value, or -1 to quit: " ); value = input.nextDouble();     } // end while   // termination phase // if user entered at least one amount... if ( valueCounter != 0 ) { if ( value>=350.00 ) { bonusCounter = bonusCounter + 1; // bonus counter // calculate commission with bonus earnings for high value item Commission = ((double) total /100)* 9+20; total = (double) total; earnings = (double)Commission + 200; } else if(value<350.00) { // calculate commission of total amount Commission = ((double) total /100)* 9; total = (double) total; earnings = (double)Commission + 200; } } // display everything System.out.printf("Items Sold : " + valueCounter); System.out.printf("\nTotal Amount: \$%.2f\n", total); System.out.printf("Commission: \$%.2f\n", Commission); System.out.printf("High profitable items: " +bonusCounter); System.out.printf("\nBonus : \$%.2f\n", bonus); System.out.printf("Earnings: \$%.2f\n", earnings); // end if     // end class Assign4   } }```
• March 2nd, 2011, 06:43 PM
Junky
Re: my High profitable items: 0 Bonus : \$0.00 why??
Code Java:

```double bonus=0; // bonus initialised to zero .... bonus = 0; // totally pointless line of code```
Where in the rest of your code do you change the value of bonus?
• March 3rd, 2011, 09:18 PM
chonch
Re: my High profitable items: 0 Bonus : \$0.00 why??
i dont get what ur asking
• March 3rd, 2011, 09:31 PM
Junky
Re: my High profitable items: 0 Bonus : \$0.00 why??
You say that the bonus variable should have the value 20. But the bonus variable is used twice in the code posted, both times it is assigned the value 0. Therefore it is impossible for it to have a value of 20.