Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Program: Create a java program that allows the user to enter a negative or positive integer as many times as the user wants. If

Java Program:

Create a java 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 sentinel-controlled while loop, so ask the user whether he/she 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 WhileIfElse.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.

image text in transcribedimage text in transcribedimage text in transcribed

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 sentinel-controlled while loop, so ask the user whether he/she 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 WhilelfE/se.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. //import statement I/class header //Begin class scope //Method header for main I/Begin method scope. 1/Declare input object for Scanner. //Declare variable called entry initialized to zero. 1/Declare variable called response initialized to blank space. I/Prompt "Do you want to enter an integer? Y or N: " //Store value in correct variable. 1/while header that tests uppercase in response I/Begin scope for while. 1/Prompt "Please enter an integer: 1/Store value in correct variable. //Clear buffer. I/Test if entry is greater than 0 //Begin if scope. //Print the number with a message that is positive, e.g., "3 is positive." //End if scope. //The option in a double-selection structure to handle if condition when false. //Begin option scope. //Test if entry is less than 0. //Begin nested if scope 1/Print the number with a message that is negative, e.g., "-3 is negative." //End nested if scope. //The option in a double-selection structure to handle nested if condition when false. //Beain nested option scope 1/Print "O is neither positive or negative." 1/End nested option scope. //End option scope. l/Prompt "Do you want to enter another integer? Y or N" 1/Store value in correct variable. I/End while scope //Exit program //End main method scope //End class scope

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

6, Why do groups need rules?

Answered: 1 week ago

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago