Question: Java Programming 1 Lab 6 : Lab Problems For all problems, use inline comments to describe major actions. Ask for assistance if needed. 1 .
Java Programming Lab :
Lab Problems
For all problems, use inline comments to describe major actions. Ask for assistance if needed.
dowhile and SentinelControlled Loops Write a Java program named LabOProbjava using a dowhile loop. During execution of the loop, ask the user for floatingpoint values from and determine the largest and smallest of those numbers. Any numbers outside of the range should be ignored. The loop should exit once the user enters a value of After the loop exits, provide descriptive text to indicate both the smallest and largest values entered up to one decimal place. The sentinel value should not be included in any calculations and you should account for the situation where NO valid values are entered
and not print a maxmin
For example, for the values the max
value is and the min value is
Expected Output valid values:
The max value was
The min value was
Expected Output no valid values:
There were no valid values
Note that the grader will provide its own input for this program and your program should correctly calculate the values for the given input, not just your tested values.
Recall that for loops can be used to calculate approximations that are represented using running sums from one number to another number. For instance, a running sum of values from inclusive on both ends can be represented in Java code as:
int sum ;
for int i ; i ; i
sum i; calculate each term
Write a Java program named LabProbjava that calculates the series represented by:
DY i
i
The program should calculate the series value based on the given summation using a for
loop and display the final result with descriptive text, and autoplaced commas.
HINT: This should result in a sum of
Expected Output:
The sum is
while Loops SentinelControlled Write a Java program named LabOProbjava that contains a while loop that can be controlled using a sentinel value. Write your loop so that only positive, even integer values are summed up and the resulting average of those numbers is output to the console once the sentinel value of is entered.
After the loop exits, provide output that includes descriptive text, the calculated sum, and the calculated average which should be limited to four decimal places. The sentinel value should not be included in any calculations. For instance, input of should provide a sum of and an average of ~
Expected Output:
For the positive, even numbers, the sum was XX and the average was XXXXX
Note that the grader will provide its own input for this program and your program should correctly calculate the values for the given input, not just your tested values.
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
