question archive a)Your friend says the following code segment finds the sum of positive numbers entered at the keyboard
Subject:Computer SciencePrice: Bought3
a)Your friend says the following code segment finds the sum of positive numbers entered at the keyboard. The keyboard entry stops if a negative number is entered. The program then displays the sum. Choose the best option among the given choices.
int s=0;
int x;
do{
String v;
v = JOptionPane.showInputDialog("Enter an integer");
x = Integer.parseInt(v);
s = s+x;
}while(x>0);
System.out.println(s);
Select one (by circling the option):
A. The program would not produce the correct result if the variable s was initialised within the body of the do-while loop due to re-initialisation during each iteration.
B. The program would also produce the correct result if the only change is to initialise s to 1 instead of 0.
C. The program would also produce the correct result if the variable s was initialised within the body of the do-while loop.
D. The do-while loop will not be executed even once in certain specific circumstances.