Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

we most use for loop like this (: Q3: Write a Java program to find the sum of positive numbers by using for loop. [Note:

image text in transcribed
image text in transcribed we most use for loop like this (:
Q3: Write a Java program to find the sum of positive numbers by using for loop. [Note: User has to enter positive numbers, when user entered a negative number it has to stop the loop and find the sum] Sample Output: Bluel: Terminal Window - Assignment1 Options Enter a number 2 Enter a number 3 Enter a number 5 Enter a number -20 Sum = 10 Can only enter input while your progra Code to Example 6: import java.util.Scanner; public class squarenumber { public static void main(String[] args) throws java.io.IOException { Scanner input = new Scanner(System.in); int number, square, counter; System.out.print("Enter up to which number you want square :: "); number = input.nextInt(); for(counter = 1; counter

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions