| | |
I think Loop problem
![]() |
I'm not getting any errors but can't get the print out I should.
Any Idea's?
Pseudo code first, then Program Code, and the printout look;
Design, code and thoroughly test the following programming problem: A company pays its salespeople a base weekly salary plus a commission based on gross sales for the week. The salespeople receive $200 per week in base salary plus 9% of their gross sales for that week. For example, a salesperson who grosses $5,000 in sales in a week receives $200 in base salary plus a commission of 9% of $5,000 ($450), or total pay of $650 for the week.
1. Write an application that enables the user to enter a salesperson’s weekly sales and calculates and displays that salesperson’s weekly pay. In addition, the application keeps track of and displays a count of the total weekly pay of salespeople by the ranges described below;
2. In addition, your program must:
2.1. Use descriptive identifier names that reveal the exact purpose of the variable in your program. Do not use abbreviations;
2.2. Enable the user to enter the weekly sales for each salesperson;
2.3. Display the weekly pay for the current salesperson;
2.4. Use a one-dimensional array of counters to keep track of how many of the salespeople earn weekly pay in each of the following nine ranges (assume that each salesperson’s weekly pay is truncated to an integer amount):
2.4.1. $200 – 299;
2.4.2. $300 – 399;
2.4.3. $400 – 499;
2.4.4. $500 – 599;
2.4.5. $600 – 699;
2.4.6. $700 – 799;
2.4.7. $800 – 899;
2.4.8. $900 – 999;
2.4.9. $1,000 and over
2.5. Locate and increment the appropriate array entry counter for salesperson’s weekly pay;
2.6. Display the array of salespeople by weekly earning ranges.
2.7. Use the techniques shown in this document’s Exhibit C, Example Program Input and Output;
2.8. Follow the UML class diagram and the pseudo code shown in the document’s “Exhibit A-1” through “Exhibit B-2”;
Exhibit A-1: UML Class Diagram of Class SalesCommission
SalesCommission
+countRanges()
Exhibit A-2: Pseudo code for countRanges Method of Class SalesCommission
A-2-01) INSTANTIATE a local variable named input of the Scanner class
A-2-02) Define a local named constant of type double named commissionRateOnGrossSales with a value of 0.09
A-2-03) Define a local named constant of type double named baseWeeklySalary with a value of 200.0
A-2-04) Define a local named constant of type double named weeklyPayRangeIncrement with a value of 100.0
A-2-05) Define a local variable of type double named salesAmount
A-2-06) Define a local variable of type double named weeklyPay
A-2-07) Define a local named constant of type int named weeklyPayRanges with a value of 9
A-2-08) Define a local variable of type int named weeklyPayRange
A-2-09) Define a local named constant of type String named salesAmountPrompt with a value of
“Enter salesperson %2d’s weekly sales, or <ctrl>z to stop: Ä
A-2-10) Define a local variable of type int named salespersonNumber with a value of 1
A-2-11) INSTANTIATE a local array variable with weeklyPayRanges elements of type int named countOfWeeklyPayByRange
A-2-12) DISPLAY the task / programmer identification line
A-2-13) DISPLAY the “Weekly Sales and Weekly Pay by Salesperson” line
A-2-14) Initialize each element of the countOfWeeklyPayByRange array to zero:
A-2-14-1) FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length – 1) BY 1
A-2-14-2) ASSIGN zero TO countOfWeeklyPayByRange [ weeklyPayRange ]
A-2-14-3) END FOR
A-2-15) Using method printf, DISPLAY the following prompt:
(“\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ” + salesAmountPrompt, salesPersonNumber)
A-2-16) WHILE (input.hasNext())
A-2-16-1) ASSIGN input.nextDouble() TO salesAmount
A-2-16-2) ASSIGN baseWeeklySalary plus (salesAmount multiplied by commissionRateOnGrossSales)
TO weeklyPay
A-2-16-3) ASSIGN (int) (weeklyPay / weeklyPayRangeIncrement) TO weeklyPayRange
A-2-16-4) IF (weeklyPayRange > (countOfWeeklyPayByRange.length + 1)) THEN
ASSIGN (countOfWeeklyPayByRange.length + 1) TO weeklyPayRange
END IF
A-2-16-5) INCREMENT countOfWeeklyPayByRange [ weeklyPayRange – 2 ]
A-2-16-6) Using method printf, DISPLAY the following prompt:
(“\t Weekly Pay for Salesperson %2d is $%,8.2f;Ä” + salesAmountPrompt,
salesPersonNumber, weeklyPay, ++salesPersonNumber)
END WHILE
A-2-17) DISPLAY the “Salesperson Count by Weekly Pay Range:” line
A-2-18) Using method printf, DISPLAY the following heading line: (“\n\t%14s\t\t%11s”, “ÄÄWeekly PayÄÄ”, “Salesperson”)
A-2-19) Using method printf, DISPLAY the following heading line: (“\n\t%14s\t\t%11s\n”, “ÄÄÄÄRangeÄÄÄÄ”, “ÄÄÄCountÄÄÄ”)
A-2-20) FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length – 2) BY 1
A-2-20-1) Using method printf, DISPLAY the following line: (“\n\t$%,5dÄ-Ä$%,5d\t\t%,6d”,
A-2-20-2) (int)( baseWeeklySalary + (weeklyPayRangeIncrement * weeklyPayRange),
A-2-20-3) (int)(99.0 + baseWeeklySalary + (weeklyPayRangeIncrement * weeklyPayRange),
A-2-20-4) countOfWeeklyPayByRange[ weeklyPayRange ] )
A-2-21) END FOR
A-2-22) Using method printf, DISPLAY the following line: (“\n\t$1,000 and over\t\t%,6d”,
countOfWeeklyPayByRange[ (countOfWeeklyPayByRange.length – 1) ] )
A-2-23) DISPLAY a blank line followed by the “End of program” line
Exhibit B-1: UML Class Diagram of Class SalesCommissionTest
SalesCommissionTest
+main(args[ ] : String)
Exhibit B-2: Pseudo code for main Method of Class SalesCommissionTest
This method has no return value and has one parameter: arg[ ] as type String.
B-2-01) INSTANTIATE object application of class SalesCommission
B-2-02) CALL application’s countRanges method
Exhibit C: Example Program Input and Output
Task blah blah
weekly sales and weekly pay by salesperson:
enter salesperson 1's weekly sales, or <ctrl>z to stop: 1000
weekly pay for salesperson 1 is $ 290.00;
enter salesperson 2's weekly sales, or <ctrl>z to stop: 2000
weekly pay for salesperson 2 is $ 380.00;
enter salesperson 3's weekly sales, or <ctrl>z to stop: 3000
weekly pay for salesperson 3is $ 470.00;
enter salesperson 4's weekly sales, or <ctrl>z to stop: 4000
weekly pay for salesperson 4 is $ 560.00;
enter salesperson 5's weekly sales, or <ctrl>z to stop: 5000
weekly pay for salesperson 5 is $ 650.00;
enter salesperson 6's weekly sales, or <ctrl>z to stop: 6000
weekly pay for salesperson 6 is $ 740.00;
enter salesperson 7's weekly sales, or <ctrl>z to stop: 7000
weekly pay for salesperson 7 is $ 830.00;
enter salesperson 8's weekly sales, or <ctrl>z to stop: 8000
weekly pay for salesperson 8 is $ 920.00;
enter salesperson 9's weekly sales, or <ctrl>z to stop: 9000
weekly pay for salesperson 9 is $ 1,010.00;
enter salesperson 10's weekly sales, or <ctrl>z to stop: ^Z
salesperson count by weekly pay range:
weekly pay salesperson
range count
$ 200 - $ 299 1
$ 300 - $ 399 1
$ 400 - $ 499 1
$ 500 - $ 599 1
$ 600 - $ 699 1
$ 700 - $ 799 1
$ 800 - $ 899 1
$ 900 - $ 999 1
$1000 and over 1
end program
Any Idea's?
Pseudo code first, then Program Code, and the printout look;
Design, code and thoroughly test the following programming problem: A company pays its salespeople a base weekly salary plus a commission based on gross sales for the week. The salespeople receive $200 per week in base salary plus 9% of their gross sales for that week. For example, a salesperson who grosses $5,000 in sales in a week receives $200 in base salary plus a commission of 9% of $5,000 ($450), or total pay of $650 for the week.
1. Write an application that enables the user to enter a salesperson’s weekly sales and calculates and displays that salesperson’s weekly pay. In addition, the application keeps track of and displays a count of the total weekly pay of salespeople by the ranges described below;
2. In addition, your program must:
2.1. Use descriptive identifier names that reveal the exact purpose of the variable in your program. Do not use abbreviations;
2.2. Enable the user to enter the weekly sales for each salesperson;
2.3. Display the weekly pay for the current salesperson;
2.4. Use a one-dimensional array of counters to keep track of how many of the salespeople earn weekly pay in each of the following nine ranges (assume that each salesperson’s weekly pay is truncated to an integer amount):
2.4.1. $200 – 299;
2.4.2. $300 – 399;
2.4.3. $400 – 499;
2.4.4. $500 – 599;
2.4.5. $600 – 699;
2.4.6. $700 – 799;
2.4.7. $800 – 899;
2.4.8. $900 – 999;
2.4.9. $1,000 and over
2.5. Locate and increment the appropriate array entry counter for salesperson’s weekly pay;
2.6. Display the array of salespeople by weekly earning ranges.
2.7. Use the techniques shown in this document’s Exhibit C, Example Program Input and Output;
2.8. Follow the UML class diagram and the pseudo code shown in the document’s “Exhibit A-1” through “Exhibit B-2”;
Exhibit A-1: UML Class Diagram of Class SalesCommission
SalesCommission
+countRanges()
Exhibit A-2: Pseudo code for countRanges Method of Class SalesCommission
A-2-01) INSTANTIATE a local variable named input of the Scanner class
A-2-02) Define a local named constant of type double named commissionRateOnGrossSales with a value of 0.09
A-2-03) Define a local named constant of type double named baseWeeklySalary with a value of 200.0
A-2-04) Define a local named constant of type double named weeklyPayRangeIncrement with a value of 100.0
A-2-05) Define a local variable of type double named salesAmount
A-2-06) Define a local variable of type double named weeklyPay
A-2-07) Define a local named constant of type int named weeklyPayRanges with a value of 9
A-2-08) Define a local variable of type int named weeklyPayRange
A-2-09) Define a local named constant of type String named salesAmountPrompt with a value of
“Enter salesperson %2d’s weekly sales, or <ctrl>z to stop: Ä
A-2-10) Define a local variable of type int named salespersonNumber with a value of 1
A-2-11) INSTANTIATE a local array variable with weeklyPayRanges elements of type int named countOfWeeklyPayByRange
A-2-12) DISPLAY the task / programmer identification line
A-2-13) DISPLAY the “Weekly Sales and Weekly Pay by Salesperson” line
A-2-14) Initialize each element of the countOfWeeklyPayByRange array to zero:
A-2-14-1) FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length – 1) BY 1
A-2-14-2) ASSIGN zero TO countOfWeeklyPayByRange [ weeklyPayRange ]
A-2-14-3) END FOR
A-2-15) Using method printf, DISPLAY the following prompt:
(“\tÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ” + salesAmountPrompt, salesPersonNumber)
A-2-16) WHILE (input.hasNext())
A-2-16-1) ASSIGN input.nextDouble() TO salesAmount
A-2-16-2) ASSIGN baseWeeklySalary plus (salesAmount multiplied by commissionRateOnGrossSales)
TO weeklyPay
A-2-16-3) ASSIGN (int) (weeklyPay / weeklyPayRangeIncrement) TO weeklyPayRange
A-2-16-4) IF (weeklyPayRange > (countOfWeeklyPayByRange.length + 1)) THEN
ASSIGN (countOfWeeklyPayByRange.length + 1) TO weeklyPayRange
END IF
A-2-16-5) INCREMENT countOfWeeklyPayByRange [ weeklyPayRange – 2 ]
A-2-16-6) Using method printf, DISPLAY the following prompt:
(“\t Weekly Pay for Salesperson %2d is $%,8.2f;Ä” + salesAmountPrompt,
salesPersonNumber, weeklyPay, ++salesPersonNumber)
END WHILE
A-2-17) DISPLAY the “Salesperson Count by Weekly Pay Range:” line
A-2-18) Using method printf, DISPLAY the following heading line: (“\n\t%14s\t\t%11s”, “ÄÄWeekly PayÄÄ”, “Salesperson”)
A-2-19) Using method printf, DISPLAY the following heading line: (“\n\t%14s\t\t%11s\n”, “ÄÄÄÄRangeÄÄÄÄ”, “ÄÄÄCountÄÄÄ”)
A-2-20) FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length – 2) BY 1
A-2-20-1) Using method printf, DISPLAY the following line: (“\n\t$%,5dÄ-Ä$%,5d\t\t%,6d”,
A-2-20-2) (int)( baseWeeklySalary + (weeklyPayRangeIncrement * weeklyPayRange),
A-2-20-3) (int)(99.0 + baseWeeklySalary + (weeklyPayRangeIncrement * weeklyPayRange),
A-2-20-4) countOfWeeklyPayByRange[ weeklyPayRange ] )
A-2-21) END FOR
A-2-22) Using method printf, DISPLAY the following line: (“\n\t$1,000 and over\t\t%,6d”,
countOfWeeklyPayByRange[ (countOfWeeklyPayByRange.length – 1) ] )
A-2-23) DISPLAY a blank line followed by the “End of program” line
Exhibit B-1: UML Class Diagram of Class SalesCommissionTest
SalesCommissionTest
+main(args[ ] : String)
Exhibit B-2: Pseudo code for main Method of Class SalesCommissionTest
This method has no return value and has one parameter: arg[ ] as type String.
B-2-01) INSTANTIATE object application of class SalesCommission
B-2-02) CALL application’s countRanges method
Java Syntax (Toggle Plain Text)
import java.util.Scanner; public class SalesCommission { // begining of countRanges method public static void countRanges() { // creates scanner to obtain input from command window Scanner input = new Scanner(System.in); final double CommssonRateOnGrossSales = 0.09; final double baseWeeklySalary = 200.0; final double weeklyPayRangeIncrement = 100.0; double salesAmount; double weeklyPay; final int weeklyPayRanges = 9; int weeklyPayRange; // define constant of type String named salesAmountPrompt final String salesAmountPrompt = ("Enter salesperson %2d's weekly sales, or <ctrl>z to stop: "); int salespersonNumber = 1; //INSTANTIATE a local array variable with weeklyPayRanges elements of type int named countOfWeeklyPayByRange final int countOfWeeklyPayByRange[]; countOfWeeklyPayByRange = new int [9]; // displays the task id and programmer System.out.println("\nTask 10-02, Ch07, Programmed by Michael Statham\n"); //Displays the Weekly Sales and Weekly Pay by Salesperson line System.out.println("Weekly Sales and Weekly Pay by Salesperson:"); //Initialize each element of the countOfWeeklyPayByRange array to zero: int countOfWeeklyPayByRanges[] = {0, /* $200-$299 */ 0, /* $300-$399 */ 0, /* $400-$499 */ 0, /* $500-$599 */ 0, /* $600-$699 */ 0, /* $700-$799 */ 0, /* $800-$899 */ 0, /* $900-$999 */ 0}; /* $1000 and over */ // FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length – 1) BY 1 //ASSIGN zero TO countOfWeeklyPayByRange [ weeklyPayRange ] for (weeklyPayRange = 0; weeklyPayRange > countOfWeeklyPayByRange.length -1; countOfWeeklyPayByRange[(int) weeklyPayRange] = 0); //END FOR //Using method printf, DISPLAY the following prompt System.out.printf ("\t "+ salesAmountPrompt, salespersonNumber); while (input.hasNext()); //ASSIGN input.nextDouble() TO salesAmount salesAmount = input.nextDouble(); //ASSIGN baseWeeklySalary + salesAmount multiplied by commissionRateOnGrossSale to weeklyPays weeklyPay = (baseWeeklySalary + salesAmount * CommssonRateOnGrossSales); //ASSIGN int weeklyPay / weeklyPayRangeIncrement to weeklyPayRange weeklyPayRange = (int) (weeklyPay/weeklyPayRange++); if (weeklyPayRange > (countOfWeeklyPayByRange.length - 1)); weeklyPayRange = (countOfWeeklyPayByRange.length -1); //End if //INCREMENT countOfWeeklyPayByRange [ weeklyPayRange - 2 ] ++countOfWeeklyPayByRange[(int) (weeklyPayRange - 2)]; //Using method printf, DISPLAY the following prompt: System.out.printf("\t Weekly Pay for Salesperson %2d is $%,8.2f; " + salesAmountPrompt, salespersonNumber, weeklyPay, ++salespersonNumber); //End while //DISPLAY the "Salesperson Count by Weekly Pay Range:" line System.out.println("Salesperson Count by Weekly Pay Range:"); //Using method printf, DISPLAY the following heading line; Weekly Pay, Salesperson System.out.printf("\n\t%14s\t\t%11s", " Weekly Pay ", "Salesperson"); //Using method printf, DISPLAY the following heading line; Range, Count System.out.printf ("\n\t%14s\t\t%11s\n", " Range ", " Count "); //FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length - 2) BY 1 for (weeklyPayRange = 0; weeklyPayRange < countOfWeeklyPayByRange.length - 2; //Using method printf, DISPLAY the following line: int baseWeeklySalary + weeklyPayRangeIncrement //* weeklyPayRange, int 99.0 + baseWeeklySalary + weeklyPayRangeIncrement * weeklyPayRange, //countOfWeeklyPayByRange weeklyPayRange System.out.printf ("\n\t$%,5d?-?$%,5d\t\t%,6d", baseWeeklySalary + (++weeklyPayRange * weeklyPayRange), + baseWeeklySalary + (weeklyPayRangeIncrement * weeklyPayRange),(countOfWeeklyPayByRange[(int) weeklyPayRange]))); //End for //Using method printf, DISPLAY the following line; 1,000 and over //count Of Weekly Pay By Range, (countOfWeeklyPayByRange.length - 1) ] ) System.out.printf ("\n\t$1,000 and over\t\t%,6d", weeklyPay, (countOfWeeklyPayByRange.length -1)); //DISPLAY a blank line followed by the "End of program" line System.out.println("\nEnd of program"); }//end method }//end SalesCommission
OutputJava Syntax (Toggle Plain Text)
//SalesCommissionTest class file name public class SalesCommissionTest { // main method begins program execution public static void main( String args[] ) { // instantiate's object application of class SalesCommission SalesCommission mySalesCommission = new SalesCommission(); // calls the application onpenForBusiness method mySalesCommission.countRanges(); }//end method main }//end class SalesCommissionTest
Exhibit C: Example Program Input and Output
Task blah blah
weekly sales and weekly pay by salesperson:
enter salesperson 1's weekly sales, or <ctrl>z to stop: 1000
weekly pay for salesperson 1 is $ 290.00;
enter salesperson 2's weekly sales, or <ctrl>z to stop: 2000
weekly pay for salesperson 2 is $ 380.00;
enter salesperson 3's weekly sales, or <ctrl>z to stop: 3000
weekly pay for salesperson 3is $ 470.00;
enter salesperson 4's weekly sales, or <ctrl>z to stop: 4000
weekly pay for salesperson 4 is $ 560.00;
enter salesperson 5's weekly sales, or <ctrl>z to stop: 5000
weekly pay for salesperson 5 is $ 650.00;
enter salesperson 6's weekly sales, or <ctrl>z to stop: 6000
weekly pay for salesperson 6 is $ 740.00;
enter salesperson 7's weekly sales, or <ctrl>z to stop: 7000
weekly pay for salesperson 7 is $ 830.00;
enter salesperson 8's weekly sales, or <ctrl>z to stop: 8000
weekly pay for salesperson 8 is $ 920.00;
enter salesperson 9's weekly sales, or <ctrl>z to stop: 9000
weekly pay for salesperson 9 is $ 1,010.00;
enter salesperson 10's weekly sales, or <ctrl>z to stop: ^Z
salesperson count by weekly pay range:
weekly pay salesperson
range count
$ 200 - $ 299 1
$ 300 - $ 399 1
$ 400 - $ 499 1
$ 500 - $ 599 1
$ 600 - $ 699 1
$ 700 - $ 799 1
$ 800 - $ 899 1
$ 900 - $ 999 1
$1000 and over 1
end program
I did some adjustment to your code(red colouring plus removed some tab characters and extra spaces) but you have to still finish it.
Now it is working trough loop, but then when you press ctrl+z it prints labels but can't get over your calculations. It will be much faster for you to check the problem then for me have go on code full of weeklyPay, weeklyPayRange etc :lol:
Good work, nice commenting (i'm in final year at uni and don't do so much
) and good luck in next progress plus don't forget bracklets in for/while/while do loops or if loops if they have to do more then one process-line of code
Now it is working trough loop, but then when you press ctrl+z it prints labels but can't get over your calculations. It will be much faster for you to check the problem then for me have go on code full of weeklyPay, weeklyPayRange etc :lol:
import java.util.Scanner;
public class SalesCommission
{
// begining of countRanges method
public static void countRanges()
{
// creates scanner to obtain input from command window
Scanner input = new Scanner(System.in);
final double CommssonRateOnGrossSales = 0.09;
final double baseWeeklySalary = 200.0;
final double weeklyPayRangeIncrement = 100.0;
double salesAmount;
double weeklyPay;
final int weeklyPayRanges = 9;
int weeklyPayRange;
// define constant of type String named salesAmountPrompt
final String salesAmountPrompt = ("Enter salesperson %2d's weekly sales, or <ctrl>z to stop: ");
int salespersonNumber = 1;
//INSTANTIATE a local array variable with weeklyPayRanges elements of type int named countOfWeeklyPayByRange
final int countOfWeeklyPayByRange[]; countOfWeeklyPayByRange = new int [9];
// displays the task id and programmer
System.out.println("\nTask 10-02, Ch07, Programmed by Michael Statham\n");
//Displays the Weekly Sales and Weekly Pay by Salesperson line
System.out.println("Weekly Sales and Weekly Pay by Salesperson:\n");
//Initialize each element of the countOfWeeklyPayByRange array to zero:
int countOfWeeklyPayByRanges[] = {0, /* $200-$299 */
0, /* $300-$399 */
0, /* $400-$499 */
0, /* $500-$599 */
0, /* $600-$699 */
0, /* $700-$799 */
0, /* $800-$899 */
0, /* $900-$999 */
0}; /* $1000 and over */
// FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length – 1) BY 1
//ASSIGN zero TO countOfWeeklyPayByRange [ weeklyPayRange ]
for (weeklyPayRange = 0; weeklyPayRange > countOfWeeklyPayByRange.length -1;
countOfWeeklyPayByRange[(int) weeklyPayRange] = 0);
//END FOR
//Using method printf, DISPLAY the following prompt
System.out.printf (salesAmountPrompt, salespersonNumber);
while (input.hasNext())
{
//ASSIGN input.nextDouble() TO salesAmount
salesAmount = input.nextDouble();
//ASSIGN baseWeeklySalary + salesAmount multiplied by commissionRateOnGrossSale to weeklyPays
weeklyPay = (baseWeeklySalary + salesAmount * CommssonRateOnGrossSales);
//ASSIGN int weeklyPay / weeklyPayRangeIncrement to weeklyPayRange
weeklyPayRange = (int) (weeklyPay/weeklyPayRange++);
if (weeklyPayRange > (countOfWeeklyPayByRange.length - 1));
weeklyPayRange = (countOfWeeklyPayByRange.length -1);
//End if
//INCREMENT countOfWeeklyPayByRange [ weeklyPayRange - 2 ]
++countOfWeeklyPayByRange[(int) (weeklyPayRange - 2)];
//Using method printf, DISPLAY the following prompt:
System.out.printf("\t Weekly Pay for Salesperson %2d is $%,8.2f; \n" + salesAmountPrompt,
salespersonNumber, weeklyPay, ++salespersonNumber);
}
//End while
//DISPLAY the "Salesperson Count by Weekly Pay Range:" line
System.out.println("Salesperson Count by Weekly Pay Range:");
//Using method printf, DISPLAY the following heading line; Weekly Pay, Salesperson
System.out.printf("\n\t%14s\t\t%11s", " Weekly Pay ", "Salesperson");
//Using method printf, DISPLAY the following heading line; Range, Count
System.out.printf ("\n\t%14s\t\t%11s\n", " Range ", " Count ");
//FOR weeklyPayRange FROM zero TO (countOfWeeklyPayByRange.length - 2) BY 1
for (weeklyPayRange = 0; weeklyPayRange < countOfWeeklyPayByRange.length - 2; weeklyPayRange++)
{
//Using method printf, DISPLAY the following line: int baseWeeklySalary + weeklyPayRangeIncrement
//* weeklyPayRange, int 99.0 + baseWeeklySalary + weeklyPayRangeIncrement * weeklyPayRange,
//countOfWeeklyPayByRange weeklyPayRange
System.out.printf ("\n\t$%,5d?-?$%,5d\t\t%,6d", baseWeeklySalary +
(++weeklyPayRange * weeklyPayRange), + baseWeeklySalary +
(weeklyPayRangeIncrement * weeklyPayRange),(countOfWeeklyPayByRange[(int) weeklyPayRange]));
}
//End for
//Using method printf, DISPLAY the following line; 1,000 and over
//count Of Weekly Pay By Range, (countOfWeeklyPayByRange.length - 1) ] )
//System.out.printf ("\n\t$1,000 and over\t\t%,6d", weeklyPay, (countOfWeeklyPayByRange.length -1));
//DISPLAY a blank line followed by the "End of program" line
System.out.println("\nEnd of program");
}//end method
}//end SalesCommissionGood work, nice commenting (i'm in final year at uni and don't do so much
) and good luck in next progress plus don't forget bracklets in for/while/while do loops or if loops if they have to do more then one process-line of code
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Yes I see some of the errors in you showed in red, ty and I see the problem lies here:
because i get duplicate local variable of
countOfWeeklyPayByRange
but I'm still working on it, and good luck in your studies as well.
//Initialize each element of the countOfWeeklyPayByRange array to zero: int countOfWeeklyPayByRange[] = {0, /* $200-$299 */ 0, /* $300-$399 */ 0, /* $400-$499 */ 0, /* $500-$599 */ 0, /* $600-$699 */ 0, /* $700-$799 */ 0, /* $800-$899 */ 0, /* $900-$999 */ 0}; /* $1000 and over */
countOfWeeklyPayByRange
but I'm still working on it, and good luck in your studies as well.
Thanx dude
if you have problem drop a message, also for future try to use litle more meaningful names or you will pay for it once
if you have problem drop a message, also for future try to use litle more meaningful names or you will pay for it once
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- nested for loop problem (Java)
- Alright this loop problem is bugging me (Java)
- Cold Fusion Loop problem (ColdFusion)
- Help w/ for loop. (C++)
- loop problem (C)
- Random Different Number in each loop ?? HLP Me PLZ (c or c++) (C++)
- loop problem (C++)
Other Threads in the Java Forum
- Previous Thread: Help Java novice
- Next Thread: triangles program
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows






