Question: Instructions: Create a program that allows the user to enter a negative or positive integer as many times as the user wants. If the user
Instructions: Create a program that allows the user to enter a negative or positive integer as many times as the user wants. If the user enters a negative integer then print the number and a message that says it's negative; otherwise, print the number and a message that says it's positive; otherwise, print a message that zero is neither negative or positive. You'll use a sentinelcontrolled while loop, so ask the user whether heshe wants to enter an integer before entering the while loop. You'll have to ask the same question again at the end of the while loop. Save the program as WhilelfElse.java. Line advance at the beginning of a prompt. Line advance at the beginning and end of a message. Your spacing is to follow the Java Style Guide.
llimport statement
Iclass header
Begin class scope.
IMethod header for main.
Begin method scope.
Declare input object for Scanner.
Declare variable called entry initialized to zero.
Declare variable called response initialized to blank space.
Prompt Do you want to enter an integer? or :
IStore value in correct variable.
while header that tests uppercase in response
Begin scope for while.
IPrompt "Please enter an integer:
Store value in correct variable.
Clear buffer
ITest if entry is greater than
Begin if scope.
Print the number with a message that is positive, eg is positive."
IEnd if scope.
The option in a doubleselection structure to handle if condition when false.
Begin option scope.
ITest if entry is less than
Begin nested if scope
Print the number with a message that is negative, eg is negative."
End nested if scope
The option in a doubleselection structure to handle nested if condition when false.
Begin nested option scope.
Print is neither positive or negative."
End nested option scope.
End option scope
IPrompt Do you want to enter another integer? or :
Store value in correct variable.
End while scope.
Exit program.
of
End main method scope.
End class scope.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
