Hey guys I got a problem, my program is suppose to take 10 numbers or grade scores and output the max, min and avg. score. My program writes out the max and the avg, although the avg dosent come out correctly because i am not getting a min for a number i am just getting 0. IK why it is reading 0 is because that is what have my int min set too. but when i remove = o just says int min does not exist for the rest of the code. here is my code thanks!

/**
 * @(#)Week_seven_number_twenty_eight.java
 *
 * Week_seven_number_twenty_eight application
 *
 * @author: Patrick Thompson 
 * @version 1.00 2012/3/14
 */
import javax.swing.JOptionPane; 
public class Week_seven_number_twenty_eight 
{
    
    public static void main(String[] args) 
    {
    	int count = 0;
    	int max = 0;
    	int min = 0;
    	int avg = 0;
    	int Total = 0;
    	for(int i = 1; i < 11;i++)
    	{
    		String NUMBER = JOptionPane.showInputDialog(null,"Please Enter a grade number");
    		int Number2 = Integer.parseInt(NUMBER);
    		System.out.println(+Number2);
    		
    		if(Number2 < min)
    		{
    			min = Number2;
    		}
    		if(Number2 > max)
    		{
    			max = Number2;
    		}
    		count++;
    		Total =+ Number2;
    	}
    	avg = Total / count;
    	System.out.println("Number of values = " + count);
        System.out.println("Maximum = "  + max);
        System.out.println("Minimum = "  + min);
        System.out.println("Average = "  + avg);
    }
}

Nvm I got it just played around with it a bit more thanks.

/**
 * @(#)Week_seven_number_twenty_eight.java
 *
 * Week_seven_number_twenty_eight application
 *
 * @author: Patrick Thompson 
 * @version 1.00 2012/3/14
 */
import javax.swing.JOptionPane;
import java.util.*;
public class Week_seven_number_twenty_eight 
{
    
    public static void main(String[] args) 
    {
Scanner keyboard = new Scanner (System.in);

                
System.out.println ("Please input the number of grades being entered: ");
int numberOfEntries = keyboard.nextInt();
System.out.println ("Enter your grade scores one at at time, followed by the enter key.");          
double next= keyboard.nextDouble();             
double max;
double min;
double sum = 0.0;
double average =.0;
max = min = next;
sum+=next;  
	                      
for (int Count = 2; Count < numberOfEntries; Count++)
{
next= keyboard.nextDouble();
//{ <<unneceaary braces
if (next > max)
max = next;
else if (next < min)
min = next;
// } <<unnecessary braces
sum = sum + next;
       
  
}
//calculating average         
average = sum / 10;
System.out.println ("The average score is "+average);
System.out.println ("The highest score is " +max);
System.out.println ("The lowest score is " +min);
}
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.