{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Sales - R L Hendrix CSC 119-01 Program 7.10 Algorithm used...

This preview shows pages 1–2. Sign up to view the full content.

R. L. Hendrix CSC 119 -01 February 16, 2011 Program # 7.10 Algorithm used to solve: I created a method called countRanges and an array named commissions to organize the numbers in order. The user gets to input the number gross sales and the program will calculate the amount of commissions and print the number of people who’s commission was in the particular range. Data used to test: import java.util.Scanner; public class Sales { public void countRanges() { Scanner input = new Scanner( System.in ); int commissions[] = new int[ 10 ]; for ( int counter = 0; counter < commissions.length; counter++ ) commissions[ counter ] = 0; System.out.print( "Enter Gross Sales ( -1 to end ): " ); double grossSales = input.nextDouble(); while ( grossSales != -1 ) { double salary = grossSales * 0.09 + 200; int range = ( int ) ( salary / 100 ); if ( range > 10 ) range = 10; ++commissions[ range - 2 ]; System.out.print( "Enter Gross Sales ( -1 to end ): " ); grossSales = input.nextDouble(); } System.out.println( "Commission Range\tNumber" ); for ( int range = 0; range < commissions.length - 1; range++ ) System.out.printf( "\$%d-\$%d\t\t%d\n",

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

Sales - R L Hendrix CSC 119-01 Program 7.10 Algorithm used...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online