Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Examine the code below, then do the following:. 1. Test it and determine whether it works as expected. 2. Write the loop with a boolean

image text in transcribed

Examine the code below, then do the following:. 1. Test it and determine whether it works as expected. 2. Write the loop with a boolean condition (not simply true.) 3. Write the loop and without using a break. int possum = 0, negsum = 0, num = 0; Scanner scanner = new Scanner(System.in); while(true) { System.out.println("Enter a number: "); num = scanner.nextInt(); if (num 0) possum += num; else break; System.out.println("possum = " + possum + " and negsum = " + negsum)

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

Step: 3

blur-text-image

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What are four FX risks faced by FIs?

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago