Question: Could you help me fix my code. and Explain what went wrong. Attempting to do a do while loop for sentinel input. /*************************************************** Program name:

Could you help me fix my code. and Explain what went wrong. Attempting to do a do while loop for sentinel input.

/***************************************************

Program name: SentinelWhileLoop

Description: Uses sentinel input to calculate sum of entered intergers

Class: CS101 sec. 5

Name: Bryan Aman

Date: 09/25/18

****************************************************/

import java.util.Scanner;

public class SentinelWhileLoop {

public static void main(String[] args) {

//Create Scanner

Scanner input = new Scanner(System.in);

//Set up Variables for use

int MAX_VALUE = 0 ;

int MIN_VALUE = 0 ;

int sum = 0 ;

//Set up do while loop

do {

//Read in input from user

System.out.print(" Enter an integer: (Enter 0(Zero) to End) ") ;

data = input.nextInt() ;

//Replace Max and Min values if needed

if (data > MAX_VALUE) {

MAX_VALUE = data ;

}

else if (data < MIN_VALUE) {

MIN_VALUE = data ;

}

//Add to sum of data

sum += data;

} while (data != 0);

//print out neccesary information

System.out.println(" Sum = " + sum) ;

System.out.println(" Largest Number =" + MAX_VALUE) ;

System.out.println(" Smallest Number =" + MIN_VALUE) ;

// find if sum is even or not and tell user

if (sum % 2 = 0) {

System.out.println("The sum is evem") ;

}

else {

System.out.println("The sum is off") ;

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!