Directions: Fill in answers on the pages below. Don't spend too much time on any one problem.
| income | taxRate |
|---|---|
| <= 10000 | 0 |
| > 10000 and <= 50000 | .20 |
| > 50000 and <= 200000 | .35 |
| > 200000 | .50 |
int income = 24000; // or some other value; double taxRate; // put if-else statement(s) here to give taxRate the proper value double tax; // statement here to give tax the proper value // statements here to print the proper message
for (int i = 1; i < 6; i++) {
System.out.println(i + " squared = " + i*i);
}
// for loop as a while below
// what the loop will print below
public class Student {
private String myName; // Student's name
private int myNumberOfCourseHours; // number of course hours
private int myTotalGradePoints; // total grade points
// put constructor below (Part a)
// put accessor method for myName below (Part b)
public int getNumberOfCourseHours() {
return myNumberOfCourseHours;
}
public int getTotalGradePoints() {
return myTotalGradePoints;
}
public void addSemester(int coursesHoursTaken, int gradePointsEarned) {
if (courseHoursTaken <= 0)
System.out.println("Incorrect input data\n");
else {
myNumberOfCourseHours = myNumberOfCourseHours + coursesHoursTaken;
myTotalGradePoints = myTotalGradePoints + gradePointsEarned;
}
}
// put definition of helper method getGPA below (Part c)
public String toString() {
return "Name: " + getName() +
"\n course hours: " + getNumberOfCourseHours() +
"\n grade points: " + getTotalGradePoints() +
"\n grade point average: " + getGPA();
}
}
//----------------------------------------------------------
public class StudentTest {
public static void main(String[] args) {
// put answers to Part d below
}
}
Date has the following parts.
If the month number is 4, 6, 9, or 11, and if the day number is 31, set the day to 1 and increase the month number by 1.
If the month number is 2, and if the day number is 29, set the day to 1 and increase the month number by 1.
Otherwise, if the day number is 32, set the day to 1 and increase the month number by 1.
After the above, if the month number is 13, set the month number to 1 and increase the year number by 1.
DateTest should the following.