Question: I need help with the following JAVA assignment For this lab, you will be writing method definitions. These method definitions will be based on method

I need help with the following JAVA assignment

For this lab, you will be writing method definitions. These method definitions will be based on method calls I have already written for you. Do all of the following steps in order. DO NOT move onto the next step until the previous one is complete.

1. Download the starting file called Lab10.javaI need help with the following JAVA assignment For this lab, you.

2. Within this file, you will find a completely written main method. Please DO NOT modify this code. Do read the code and familiarize yourself with what it does. Specifically focus on the method calls.

3. Write the method stubs (just like we did in class) for all the methods. Once you complete this, the program will compile and you will be able to test each method as you write it completely. Remember, a method stub includes the method name, all input parameters and the output type. If the method returns a value, you should write a return statement that just returns a default value. Without this, it will not compile. Therefore, the method body should only be one line of code.

4. Write a JavaDoc method header for each method. This will include a method description and any necessary parameter and return value descriptions. Make sure you view the Java documentation to see if your JavaDoc code works.

5. Write the method definitions one by one for all methods, testing after each one. In doing this you must ask yourself the following questions for each:

a. What information does the method need?

b. What information should the method return?

c. What is the method name?

d. What does the method do?

6. In the main method, I have included lots of tests for each method. Make sure to test each method as you write it. The main method should run completely once you have all of the method definitions correctly written.

Lab10.java:

import java.util.Scanner;

/**

* This is the starting file for Lab 10.

*

* @author (your name)

* @version (a version number or a date)

*/

public class Lab10

{

/**

* The main method tests all four method definitions.

*

* @param args A string array of input arguments

*/

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

/**

* Method one checks to see if a number is even or odd.

*/

System.out.println("Testing method one");

// Test with real value

String ans1 = evenOrOdd(7); // odd

System.out.println("7 is an " + ans1 + " number.");

// Test with user input

System.out.println("Please enter an integer: ");

int num = input.nextInt();

String ans2 = evenOrOdd(num);

System.out.println("The integer is an " + ans2 + " number.");

/**

* Method two checks to see if either of the strings appears

* at the very end of the other string, ignoring upper/lower

* case differences (in other words, the computation should

* not be "case sensitive").

*/

System.out.println(" Testing method two");

// Test with real values

boolean end1 = endOther("Hiabc", "abc"); // true

boolean end2 = endOther("AbC", "HiaBc"); // true

boolean end3 = endOther("abcXYZ", "abcDEF"); // false

System.out.println("The booleans are: " + end1 + ", " + end2 +

", " + end3);

// Test with user input

System.out.println();

System.out.println("Please enter the first string: ");

String first = input.next();

System.out.println("Please enter the second string: ");

String second = input.next();

boolean end4 = endOther(first, second);

if (end4) {

System.out.println(" One of the strings appears at the end of

the other string.");

} else {

System.out.println(" Neither of the strings appears at the

end of the other string.");

}

/**

* This method should return the sum of three numbers.

* However, if one of the numbers is 13 then it does not

* count toward the sum and the parameters to its right

* do not count either. So, if the second number is 13,

* then the second and the third number do not count toward

* the sum.

*/

System.out.println(" Testing method three");

// Test with real values

int sum1 = luckySum(4, 2, 3); // 9

int sum2 = luckySum(13, 2, 9); // 0

int sum3 = luckySum(9, 4, 13); // 13

double sum4 = luckySum(7.2, 3.4, 13.0); //10.6

double sum5 = luckySum(6.57, 13.0, 10.1); // 6.57

System.out.println("The lucky sums are: " + sum1 + ", " + sum2 +

", " + sum3 + ", " + sum4 + ", " + sum5);

// Test with user input

System.out.println(" Please enter the first number:");

int num1 = input.nextInt();

System.out.println("Please enter the second number:");

int num2 = input.nextInt();

System.out.println("Please enter the third number:");

int num3 = input.nextInt();

int lucky = luckySum(num1, num2, num3);

System.out.println("The lucky sum is " + lucky);

}

// Please write your methods here. Include JavaDoc method headers.

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!