You are on page 1of 3

PRG/420 Java Programming I - Week 3

Week Three: Conditional and Iterative Structures

Discussion Question : Loops

Our focus this week is loops. Select and complete one of the following activities: Convert the following program from for loop to while loop.

class ArithmeticProgression { public static void main (String [] args) { int sum = 0;

for (int i = 1; i <= 1000; i++) { sum = sum + i; System.out.println(Integer.toString(sum)); } } }

Compare the efficiency between a for loop and a while loop in the same program. Your program should be able to tell if a for loop is faster than a while-loop at the end of the program. Include the result of your run with the information on which one is faster.

Discussion Question : Three Kinds of Loops

There are 3 kinds of loopsfor loop, while loop, and do while loop. Under which circumstances would each kind of loop be more appropriate? Explain your answers using specific examples.

Individual Simple Commission Calculation Program Part 2

Modify the Week Two Java application using Java NetBeans IDE to meet these additional and changed business requirements: The company has recently changed its total annual compensation policy to improve sales.

A salesperson will continue to earn a fixed salary of $50,000. The current sales target for every salesperson is $120,000. The sales incentive will only start when 80% of the sales target is met. The current commission is 5% of total sales. If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.5. The application should ask the user to enter annual sales, and it should display the total annual compensation. The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salespersons annual sales, until it reaches 50% above the salespersons annual sales.

Sample Table: Assuming a total annual sales of $100,000, the table would look like this:

Total Sales

Total Compensation

100,000 <<Program calculated value>> 105,000 <<Program calculated value>> 110,000 <<Program calculated value>> 115,000 <<Program calculated value>> 120,000 <<Program calculated value>> 125,000 <<Program calculated value>> 130,000 <<Program calculated value>> 135,000 <<Program calculated value>> 140,000 <<Program calculated value>> 145,000 <<Program calculated value>>

150,000 <<Program calculated value>>

The Java application should also meet these technical requirements:

class.

The application should have at least one class, in addition to the applications controlling The source code must demonstrate the use of conditional and looping structures. There should be proper documentation in the source code.

CLICK HERE TO GET THE SOLUTION !!!!!!!