Sales - R. L. Hendrix CSC 119 -01 February 16, 2011 Program...

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

View Full Document Right Arrow Icon
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" );
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

Sales - R. L. Hendrix CSC 119 -01 February 16, 2011 Program...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online