Task #5: Sentinel values for terminating loops
Students will write a java program that asks the user to input their weekly salary or -1 to terminate.
After totaling up all the salaries, you will calculate the average salary. You will need to maintain a counter for this purpose.
Method of iteration: while loop with a sentinel value of -1
Test cases:
1. the user enters -1 from the very beginning
2. enter the four salaries for a month and calculate their average:
wk1 650
wk2 750
wk3 810
wk4 450
Sample Run:
Enter your salaries, or enter -1 to terminate: 10 10 40 -1
Your average salary is $20.00