Question: Fix the errors to have the JUnit pass all tests. COPIED CODE: /** * Name: Firstname and Lastname * This goes with chapter 3 and

Fix the errors to have the JUnit pass all tests.

Fix the errors to have the JUnit pass all tests. COPIED CODE:

/** * Name: Firstname and Lastname * This goes with chapter 3

and deals with selection statements * such as IF THEN ELSE *

* @version 3.0 * */ public class JU11V { // declare your

COPIED CODE:

/**

* Name: Firstname and Lastname

* This goes with chapter 3 and deals with selection statements

* such as IF THEN ELSE

*

* @version 3.0

*

*/

public class JU11V

{

// declare your constants here to fix "magic" numbers.

/**

* Write a method that returns if a number is positive, negative, or zero.

*

*

 

* For Example:

* posZeroNeg(-4) -> "-4 is negative."

* posZeroNeg(42) -> "42 is positive."

* posZeroNeg(0) -> "0 is zero."

*

*

* @param number

* @return read the description and unit tests.

*/

public static String posZeroNeg(int number)

{

String response = "";

// TODO: Finish

// if (number > 0)

// {

// response = number + " is positive.";

// }

// more code needed.

return response;

}

/**

* Determines if a number is even or odd. For example:

*

*

 

* isEvenOrOdd(5) -> "5 is odd."

* isEvenOrOdd(10) -> "10 is even."

*

*

* @param number

* @return

*/

public static String isEvenOrOdd(int number)

{

String answer = "";// declare a String variable answer and assign it empty

// string (which is different than null)

// note if you just declare a String variable without initializing it,

// it will have the value null.

//TODO: Put code here.

return answer;

}

/**

* If the number is a multiple of 5, return "HiFive" If the number is even,

* return "HiEven" If they are both even and multiple of five, then return

* "HiFiveAndEven" If neither is the case, return "Sorry" Hint: Look at page

* 75 in the eBook.

*

* @param number

* @return

*/

public static String simpleIf(int number)

{

String answer = ""; // declare a String variable answer and assign it

// "Sorry".

/*

* Hint, you can use this code if you wish.... or not. if (number % 5 == 0)

* { answer = "HiFive"; } if (number % 2

*

*

* number % 5 != 0 && number % 2 != 0) { answer = "Sorry"; }

*/

return answer;

}

/**

* The score parameter receives a score from 0.0 to 100.0. This method will

* return the letter grade that matches the score. For example, an 86.5 would

* return a "B", a 90.1 would return an "A". Any score under 60 would receive

* an "F".

*

* @param score

* @return

*/

public static String getLetterGrade(int score)

{

String letterGrade = "";

/*

* if (score >= 90) { letterGrade = "A"; } else if (score >= 80)

*/

return letterGrade;

}

/**

* Determines if the String's a, b, c are sorted in alphabetical order.

* Returns a sentence that says if they are in order or not.

*

*

 

* Examples:

* inAlphabeticalOrder("acorn", "apple", "pizza") -> "acorn, apple, and pizza are in alphabetical order."

* inAlphabeticalOrder("bear", "morning", "zebra") -> "bear, morning, and zebra are in alphabetical order."

* inAlphabeticalOrder("giraff", "morning", "zebra") -> "bear, morning, and zebra are NOT in alphabetical order."

*

*

*/

public static String inAlphabeticalOrder(String a, String b, String c)

{

return "Fix this so that it passes the tests";

}

/**

* Create a String made up of just the first two letters. Hashtags are used if

* there are not enough letters.

*

*

 

* firstTwoCharacters("superman") -> "su"

* firstTwoCharacters("e") -> "e#"

* firstTwoCharacters("") -> "##"

*

*

* @param phrase

* != null

* @return the first two letters, or hashtags if there's not enough letters

* for that.

*/

public static String firstTwoCharacters(String phrase)

{

return "TODO: Write the body of this method so the test passes.";

}

}

JU11v.java Wednesday, January 6, 2021, 2:49 PM * 1 /** 2 * Name: Firstname and Lastname 3 * This goes with chapter 3 and deals with selection statements 4 * such as IF THEN ELSE 5 * 6 * @version 3.0 7 * 8 */ 9 10 public class JU11V 11 12 // declare your constants here to fix "magic" numbers. 13 14 /** 15 * Write a method that returns if a number is positive, negative, or zero. 16 17 *

 18 * For Example: 19 * posZeroNeg(-4) -> "-4 is negative." 20 * posZeroNeg (42) -> "42 is positive." 21 * posZeroNeg(0) -> "O is zero." 22 * 

23 24 * @param number 25 * @return read the description and unit tests. 26 */ 27 public static String posZeroeg int number 28 29 String response 30 // TODO: Finish 31 // if (number > 0) 32 // { 33 // response = number + " is positive."; // } 35 // more code needed. 36 return response; 37 38 39 /*** 40 * Determines if a number is even or odd. For example: 41 42 *

 43 * isEvenorodd(5) -> "5 is odd." ** 34 Page 1 57 JU11v.java Wednesday, January 6, 2021, 2:49 PM 44 * isEvenorodd (10) -> "10 is even." 45 * 

46 47 * @param number 48 * @return 49 */ 50 public static String is EvenOrodd int number 51 52 String answer = ":// declare a String variable answer and assign it empty 53 // string (which is different than null) 54 55 // note if you just declare a String variable without initializing it, 56 // it will have the value null. 58 //TODO: Put code here. 59 return answer; 60 61 62 63 /** 64 * If the number is a multiple of 5, return "HiFive" If the number is even, 65 * return "HiEven" If they are both even and multiple of five, then return 66 * "HiFiveAndEven" If neither is the case, return "Sorry" Hint: Look at page 67 * 75 in the eBook. 68 69 * @param number * @return 71 */ 72 public static String simpleIf int number 74 String answer = ""; // declare a String variable answer and assign it 75 // "Sorry": 76 77 /* 78 * Hint, you can use this code if you wish.... or not. if (number % 5 == 0) * { answer = "HiFive"; } if (number % 2 80 70 ** Page 2 JU11v.java Wednesday, January 6, 2021, 2:49 PM 81 82 83 84 85 * number % 5 != 0 && number % 2 != 0) { answer = "Sorry"; } */ return answer; 86 87 /** 88 * The score parameter receives a score from 0.0 to 100.0. This method will 89 * return the letter grade that matches the score. For example, an 86.5 would 90 * return a "B", a 90.1 would return an "A". Any score under 60 would receive 91 * an "F". 92 93 * @param score 94 * @return 95 */ 96 public static String getLetterGrade int score 97 98 String letterGrade 99 /* 100 * if (score >= 90) { letterGrade = "A"; } else if (score >> 80) 101 */ 102 103 return letterGrade; 104 105 106 /** 107 * Determines if the String's a, b, c are sorted in alphabetical order. 108 * Returns a sentence that says if they are in order or not. 109 110 *

 111 * Examples: 112 * inAlphabeticalOrder("acorn", "apple", "pizza") -> "acorn, apple, and pizza are in alphabetical order." 113 * inAlphabeticalOrder("bear", "morning", "zebra") -> "bear, morning, and zebra are in alphabetical order." 114 * inAlphabeticalOrder("giraff", "morning", "zebra") -> "bear, morning, and zebra are NOT in alphabetical order." 115 * 

116 * JU11v.java Wednesday, January 6, 2021, 2:49 PM 117 */ 118 public static String inAlphabeticalOrder String a, String b, String c 119 120 return "Fix this so that it passes the tests"; 121 122 123 /** 124 * Create a String made up of just the first two letters. Hashtags are used if 125 * there are not enough letters. 126 127 *

 128 * firstTwoCharacters("superman") -> "su" 129 * first TwoCharacters("e") -> "e# 130 * firstTwoCharacters("") -> "## 131 * 

132 133 * @param phrase 134 != null 135 * @return the first two letters, or hashtags if there's not enough letters 136 * for that. 137 */ 138 public static String firstTwoCharacters String phrase 139 140 return "TODO: Write the body of this method so the test passes." 141 142 143 144 145 146

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!