Assignment Scope
- Netbeans IDE familiarity
- Create a Java console project
- Create a package
- Create a class
- Write simple Java source code
- Use a Java API library class and a static method to write output to the output console
- Compile and run a project
- Compress a project and submit to Webcourses
References
- docx
- Setting up a project in Netbeans.docx
- Netbeans right click menu help.docx
Deliverables
To complete this assignment you must submit your compressed Netbeans project to Webcourses.
Tasks and Rubric
Activity | |
AssignmentOne project | Create a new Java Application project named AssignmentOneallowing Netbeans IDE to create the main class called Comparision.java |
AssignmentOne class | Method main() should:1. In the main method call the following methods:a. comparison();b. forLoop();c. whileSwitch(); |
Write method comparison() to do the following:1. Return type of void2. Declare as static3. Empty parameter list4. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in5. Declare two variables of primitive data type int representing two numbers6. Using method System.out.println(), prompt the user to enter an integer7. Store the value in one of the variables of primitive data type int by setting it equal to method nextInt() in class Scanner8. Using method System.out.println(), prompt the user to enter a second integer9. Store the value in the second variable of primitive data type int by setting it equal to method nextInt() in class Scanner10. Using the comparison operators, determine if the two variables of primitive data type int area. Equalb. Not equalc. Less thand. Greater thane. Less than or equal tof. Greater than or equal to11. Output to the console the results of each comparison | |
Write method forLoop() to do the following:1. Return type of void2. Declare as static3. Empty parameter list4. Declare the following variables all of primitive data type doublea. amount = 0;b. principle;c. rate;d. time;e. ci;f. t = 1;5. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in6. Using method System.out.println(), prompt the user to enter the initial principle investment7. Store the value in the variable principle by setting it equal to method nextDouble() in class Scanner8. Using method System.out.println(), prompt the user to enter the interest rate9. Store the value in the variable rate by setting it equal to method nextDouble() in class Scanner10. Using method System.out.println(), prompt the user to enter the number of years of the investment11. Store the value in the variable time by setting it equal to method nextDouble() in class Scanner12. Update the value of variable rate by setting it equal to the calculation (1 + rate / 100) to generate a percentage value13. In a for loopa. Loop for the number of years stored in the variable timeb. Set variable t equal (t * rate)14. Update variable amount setting it equal to the calculation (principle * t)15. Output to the user the amount16. Calculate the compounded interest, setting variable ci equal to the calculation (amount principle)17. Output to the user their compounded interest | |
Write method whileSwitch() to do the following:1. Return type of void2. Declare as static3. Empty parameter list4. Declare the following variables all of primitive data type inta. dayb. rain5. In a while loop that loops for seven daysa. In a switch that evaluates the variable dayi. If case 01. Output to the console Sunday we got 1 inch of rain2. Update variable rain to equal (rain + 1)ii. If case 11. Output to the console Monday we got 2 inches of rain2. Update variable rain to equal (rain + 2)iii. If case 21. Output to the console Tuesday we got 3 inches of rain2. Update variable rain to equal (rain + 3)iv. If case 31. Output to the console Wednesday we got 4 inches of rain2. Update variable rain to equal (rain + 4)v. If case 41. Output to the console Thursday we got 5 inches of rain2. Update variable rain to equal (rain + 5)vi. If case 51. Output to the console Friday we got 6 inches of rain2. Update variable rain to equal (rain + 6)vii. If case 61. Output to the console Saturday we got 7 inch of rain2. Update variable rain to equal (rain + 7)viii. Default case1. Output to the console that the value is not validb. Increment the looping variable day by 16. Output to the console how much rain was received in the past week | |
Java application | |
Test Case 1 | Test Case 1 passes |
Test Case 2 | Test Case 2 passes |
Test Case 3 | Test Case 3 passes |
Test Case 4 | Test Case 4 passes |
Source compiles with no errors | |
Source runs with no errors | |
Source includes comments |
Perform the following test cases
Test Cases | ||
Action | Expected outcome | |
Test Case 1 | Project view | Completed project view should look like Figure 1 |
Test case 2 | Run application | The console window should look similar to Figure 2 |
Test case 3 | Run application | The console window should look similar to Figure 3 |
Test case 4 | Run application | The console window should look similar to Figure 4 |
Figure 1 Project View
Figure 2 Output in console window
Figure 3 Output in console window
Figure 4 Output in console windows
Reviews
There are no reviews yet.