Activity AssignmentOne project Create a new Java Application project named Assig
ID: 3745007 • Letter: A
Question
Activity
AssignmentOne project
Create a new Java Application project named AssignmentOne
allowing Netbeans IDE to create the main class called AssignmentOne.java
AssignmentOne class
Method main() should:
a. comparison();
b. forLoop();
c. whileSwitch();
Write method comparison() to do the following:
1. Return type of void
2. Declare as static
3. Empty parameter list
4. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in
5. Declare two variables of primitive data type int representing two numbers
6. Using method System.out.println(), prompt the user to enter an integer
7. Store the value in one of the variables of primitive data type int by setting it equal to method nextInt() in class Scanner
8. Using method System.out.println(), prompt the user to enter a second integer
9. Store the value in the second variable of primitive data type int by setting it equal to method nextInt() in class Scanner
a. Equal
b. Not equal
c. Less than
d. Greater than
e. Less than or equal to
f. Greater than or equal to
11. Output to the console the results of each comparison
Write method forLoop() to do the following:
1. Return type of void
2. Declare as static
3. Empty parameter list
a. amount = 0;
b. principle;
c. rate;
d. time;
e. ci;
t = 1;
5. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in
6. Using method System.out.println(), prompt the user to enter the initial principle investment
7. Store the value in the variable principle by setting it equal to method nextDouble() in class Scanner
8. Using method System.out.println(), prompt the user to enter the interest rate
9. Store the value in the variable rate by setting it equal to method nextDouble() in class Scanner
10. Using method System.out.println(), prompt the user to enter the number of years of the investment
11. Store the value in the variable time by setting it equal to method nextDouble() in class Scanner
12. Update the value of variable rate by setting it equal to the calculation (1 + rate / 100) to generate a percentage value
a. Loop for the number of years stored in the variable time
b.Set variable t equal (t * rate)
14. Update variable amount setting it equal to the calculation (principle * t)
15. Output to the user the amount
16. 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 void
2. Declare as static
3. Empty parameter list
a. day
b. rain
5. In a while loop that loops for seven days
a. In a switch that evaluates the variable day
i. If case 0
1. Output to the console “Sunday we got 1 inch of rain”
2. Update variable rain to equal (rain + 1)
1. Output to the console “Monday we got 2 inches of rain”
2. Update variable rain to equal (rain + 2)
Output to the console “Tuesday we got 3 inches of rain”
Update variable rain to equal (rain + 3)
Output to the console “Wednesday we got 4 inches of rain”
Update variable rain to equal (rain + 4)
Output to the console “Thursday we got 5 inches of rain”
Update variable rain to equal (rain + 5)
Output to the console “Friday we got 6 inches of rain”
Update variable rain to equal (rain + 6)
Output to the console “Saturday we got 7 inch of rain”
Update variable rain to equal (rain + 7)
Output to the console that the value is not valid
b. Increment the looping variable day by 1
6. 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
MUST BE WRITTEN IN JAVA! THANK YOU!!!
Activity
AssignmentOne project
Create a new Java Application project named AssignmentOne
allowing Netbeans IDE to create the main class called AssignmentOne.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 void
2. Declare as static
3. Empty parameter list
4. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in
5. Declare two variables of primitive data type int representing two numbers
6. Using method System.out.println(), prompt the user to enter an integer
7. Store the value in one of the variables of primitive data type int by setting it equal to method nextInt() in class Scanner
8. Using method System.out.println(), prompt the user to enter a second integer
9. Store the value in the second variable of primitive data type int by setting it equal to method nextInt() in class Scanner
10. Using the comparison operators, determine if the two variables of primitive data type int area. Equal
b. Not equal
c. Less than
d. Greater than
e. Less than or equal to
f. Greater than or equal to
11. Output to the console the results of each comparison
Write method forLoop() to do the following:
1. Return type of void
2. Declare as static
3. Empty parameter list
4. Declare the following variables all of primitive data type doublea. amount = 0;
b. principle;
c. rate;
d. time;
e. ci;
t = 1;
5. Instantiate and instance of class Scanner, pass as an argument to the constructor the value System.in
6. Using method System.out.println(), prompt the user to enter the initial principle investment
7. Store the value in the variable principle by setting it equal to method nextDouble() in class Scanner
8. Using method System.out.println(), prompt the user to enter the interest rate
9. Store the value in the variable rate by setting it equal to method nextDouble() in class Scanner
10. Using method System.out.println(), prompt the user to enter the number of years of the investment
11. Store the value in the variable time by setting it equal to method nextDouble() in class Scanner
12. Update the value of variable rate by setting it equal to the calculation (1 + rate / 100) to generate a percentage value
13. In a for loopa. Loop for the number of years stored in the variable time
b.Set variable t equal (t * rate)
14. Update variable amount setting it equal to the calculation (principle * t)
15. Output to the user the amount
16. 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 void
2. Declare as static
3. Empty parameter list
4. Declare the following variables all of primitive data type inta. day
b. rain
5. In a while loop that loops for seven days
a. In a switch that evaluates the variable day
i. If case 0
1. Output to the console “Sunday we got 1 inch of rain”
2. Update variable rain to equal (rain + 1)
ii. If case 11. Output to the console “Monday we got 2 inches of rain”
2. Update variable rain to equal (rain + 2)
iii. If case 2Output to the console “Tuesday we got 3 inches of rain”
Update variable rain to equal (rain + 3)
iv. If case 3Output to the console “Wednesday we got 4 inches of rain”
Update variable rain to equal (rain + 4)
v. If case 4Output to the console “Thursday we got 5 inches of rain”
Update variable rain to equal (rain + 5)
vi. If case 5Output to the console “Friday we got 6 inches of rain”
Update variable rain to equal (rain + 6)
vii. If case 6Output to the console “Saturday we got 7 inch of rain”
Update variable rain to equal (rain + 7)
viii. Default caseOutput to the console that the value is not valid
b. Increment the looping variable day by 1
6. 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
Projects X Files AssignmentOne Source Packages E assignmentne Test Packages Libraries Test Libraries Figure 1 Project View Output-Comparison (run) X Eun Enter first integer 23 Enter second integer 25 23 -25 23Explanation / Answer
package org.students;
import java.util.Scanner;
public class Assignment {
public static void main(String[] args) {
comparision();
forLoop();
whileSwitch();
}
private static void whileSwitch() {
int day=0,rain=0;
while(day<7)
{
switch(day)
{
case 0:{
System.out.println("Sunday we got 1 inch of rain");
rain=rain+1;
break;
}
case 1:{
System.out.println("Monday we got 2 inch of rain");
rain=rain+2;
break;
}
case 2:{
System.out.println("Tuesday we got 3 inch of rain");
rain=rain+3;
break;
}
case 3:{
System.out.println("Wednesday we got 4 inch of rain");
rain=rain+4;
break;
}
case 4:{
System.out.println("Thursday we got 5 inch of rain");
rain=rain+5;
break;
}
case 5:{
System.out.println("Friday we got 6 inch of rain");
rain=rain+6;
break;
}
case 6:{
System.out.println("Saturday we got 7 inch of rain");
rain=rain+7;
break;
}
default:
{
System.out.println("Output to the console that the value is not valid");
break;
}
}
day++;
}
System.out.println("We got "+rain+" inches of rain this week! Please stop raining.");
}
private static void forLoop() {
double amount = 0;
double principle;
double rate;
double time;
double ci;
double t = 1;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
System.out.print("Enter initial principle :");
principle = sc.nextDouble();
System.out.print("Enter interest rate :");
rate = sc.nextDouble();
System.out.print("Enter investment years :");
time = sc.nextDouble();
rate = (1 + rate / 100);
for (int i = 1; i <= time; i++) {
t = t * (rate);
amount = (principle * t);
}
System.out.println("Amount:" + amount);
ci = (amount - principle);
System.out.println("Compound Interest:" + ci);
}
private static void comparision() {
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
// Declaring variables
int first, second;
// Getting the input entered by the user
System.out.print("Enter first number :");
first = sc.nextInt();
System.out.print("Enter second number :");
second = sc.nextInt();
if (first == second) {
System.out.println(first + "==" + second);
} else {
System.out.println(first + "!=" + second);
}
if (first < second) {
System.out.println(first + "<" + second);
} else {
System.out.println(first + ">" + second);
}
if (first <= second) {
System.out.println(first + "<=" + second);
} else {
System.out.println(first + ">=" + second);
}
}
}
_________________
Output:
Enter first number :23
Enter second number :25
23!=25
23<25
23<=25
Enter initial principle :2000
Enter interest rate :10
Enter investment years :5
Amount:3221.0200000000013
Compound Interest:1221.0200000000013
Sunday we got 1 inch of rain
Monday we got 2 inch of rain
Tuesday we got 3 inch of rain
Wednesday we got 4 inch of rain
Thursday we got 5 inch of rain
Friday we got 6 inch of rain
Saturday we got 7 inch of rain
We got 28 inches of rain this week! Please stop raining.
_______________Could you plz rate me well.Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.