In this assignment you will use a loop and a custom method (called a "function"), as well as built-in Java classes. Create a Java program that meets the following requirements: Ask the user for input...


In this assignment you will use a loop and a custom method (called a "function"), as well as built-in Java classes. Create a Java program that meets the following requirements:



  1. Ask the user for input using the following prompt (precisely): "Please enter a number between 15 and 45. Enter 1 to exit."

  2. Store the user's input in a variable with the integer data type.

  3. Use a while loop to repeat the program, checking the user's entry in case they entered a 1 to exit the program. (1) Within the loop, place the prompt (user instructions) described above. (2) Next, within the loop, collect the user's input and store it in a variable. (3) Finally, still within the loop, display the output string precisely as follows, then call the checkEntry method, passing in the variable containing the user's input. "Output: " (do not forget the space after the colon)

  4. A separate method called "checkEntry" has been created for you in the starting template below (note: You can restore the default code if you wish to start over by clicking the "Load default template…" link). Within this method, create an IF and an ELSE, using a condition for the IF that checks to see if the value is greater than or equal to 35. If the user enterd a value of less than 35, the checkEntry method must multiply that value by 5 and return the result to main(). If the user enterd a valuegreater than or equal to35, the program must instead add 10 to their number and return the result to main().


Sample Values for Testing (paste into the "Enter program input (optional)" box below):



import java.util.Scanner;





public class LabProgram {


public static void main(String[] args) {


/* Type your code below this line. Create additional lines as needed. */






} // do not delete this line






public static int checkEntry(int incoming) {


/* Type your code for the checkEntry method below this line. Create additional lines as needed. */






} // do not delete this line

} // do not delete this line





Sep 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here