int sum = 0;
int count;
for( count=0; count <=4; count++){
sum += count;
}
System.out.println("sum= " + sum);
2. What would you find on the screen?
a. sum = 1
b. sum = 6
c. sum = 10
d. error message
3. What is the value of count after execution of the for loop?
a. 0
b. 4
c. 5
4. How many times are the statements inside the loop executed?
a. 0
b. 4
c. 5
d. 6
Write the class Calculate that contains all
static methods. The public interface for this class is below
Test your class using the examples described in the interface.
Teachers are paid on a salary schedule that
provides a salary based on their number of years of teaching
experience. Write a class TeacherSalary that
stores a beginning salary for a teacher, the number of years experience
and the percent increase for each year (as a decimal) . This
class should contain the following methods:
double
getBeginningSalary() // returns the beginning salary for this
teacher
int getYears() // returns
the years experience
double getPercent() // returns the percent increase for each year
double
salaryAfterExperience() // returns the salary after years
experience
// This method should NOT change the value of the beginning salary
For example,
a teacher with a beginning salary of $16000, 10 years experience and a
4% increase each year would produce the following
table.
Sample output: Years
Experience
Salary
-----------------------------
1
16000
2
16640
3
17306
:
:
10
22773 (value returned by salaryAfterExperience()
)