Suppose sum and num are int variables, and the input is 20 25 10 18 -1 What is the output of the following code? (Assume that console is a Scanner object initialized to the standard input device.) sum = 0; num = console.nextInt() ; while (num != -1) {if (num >= 20) sum = sum + num; else sum = sum - num; num = console.nextInt() ;} System.out.println(sum) ;
A) 17
B) 28
C) 45
D) 60
Correct Answer:
Verified
Q25: What is value of x after the
Q26: After a break statement executes, the program
Q27: Because a do...while loop is a post-test
Q28: Which of the following is true about
Q29: What is the output of the following
Q31: Which of the following is the update
Q32: What is the value of counter after
Q33: If a continue statement is placed in
Q34: The do...while loop has an exit condition
Q35: What is the tenth Fibonacci number in
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents