Question: How do you fix this code snippet to make it print out the sum when the user enters a letter rather than a double? The
How do you fix this code snippet to make it print out the sum when the user enters a letter rather than a double? The user must enter at least one double when the program begins.
System.out.printEnter a value: ;
double sum ;
Scanner in new ScannerSystemin;
boolean hasData true;
do
double value innextDouble;
sum sum value;
System.out.printEnter a value to add, or a letter to quit: ;
while inhasNext;
System.out.printlnsum sum;
Question options:
while inhasData;
while inhasEnded;
while inhasNextDouble;
while hasData;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
