static void main(String anner in = new Scanner(S: stem.out.print("Enter a t num = in.nextInt(); %3D Step 2: Declare a doubl an initial valu Step 3: Use a while lo0 all integers fr to sum. You can have an additio Step 4: Display the sum Sample output for num = " The sum of square roots

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
ミミミ
* dauthor
10
* @version
11
*/
public class SumofSqrt
{
12
13
I
public static void main(String [] args)
{
15
Scanner in = new Scanner(System.in);
System.out.print("Enter a positive integer: ");
int num = in.nextInt();
16
17
18
19
20
// Step 2: Declare a double variable sum with
21
//
an initial value of zero
22
23
// Step 3: Use a while loop to add square roots of
all integers from 1 to num, inclusive,
25
26
//
to sum.
27
// You can have an additional variable if needed.
28
29
// Step 4: Display the sum on one line with 6 decimal digits
// Sample output for num = 5
// The sum of square roots: 8.382332.
30
31
32
33
35
}
36
37
Transcribed Image Text:ミミミ * dauthor 10 * @version 11 */ public class SumofSqrt { 12 13 I public static void main(String [] args) { 15 Scanner in = new Scanner(System.in); System.out.print("Enter a positive integer: "); int num = in.nextInt(); 16 17 18 19 20 // Step 2: Declare a double variable sum with 21 // an initial value of zero 22 23 // Step 3: Use a while loop to add square roots of all integers from 1 to num, inclusive, 25 26 // to sum. 27 // You can have an additional variable if needed. 28 29 // Step 4: Display the sum on one line with 6 decimal digits // Sample output for num = 5 // The sum of square roots: 8.382332. 30 31 32 33 35 } 36 37
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY