I need help making a java program that will allow me to input 10 test grades into an array using a dialog box in one method. Then in a different method it needs to display the grades and calculate the average, highest, and lowest grade. I have no idea where to start and need a lot of help please.
Sounds like a class assignment - and if that is, we aren't going to do it for you Smile
Here are several questions:
* what is the mathematical definition of the average, min and max functions ?
* in Java, do you know what data types you can use ?
* have you looked around for the ways to read input and print output (hint, the canonical Java Hello World example shows how to print output) ?
Ok I have made a method for you that takes in 10 grades and stores it into an array. You should use the console class for basic input and system.out for output. I will leave it up to you to implement the methods to return average, high, and low. If you have any questions feel free to post here. Good luck!


Code:
import java.io.Console;

public class testGradesCemetech
{
   private int[] gradeArray=new int[10];
   
   
   public testGradesCemetech()
   {
      System.out.println("Please enter 10 grades");
      for (int i=0 ; i<10 ; i++)
      {
         Console console = System.console();
         String grade = console.readLine("Enter grade:");
         gradeArray[i]=Integer.parseInt(grade);
      }
   }
   
   public void dispGrades()
   {
      for (int i:gradeArray)
      {
         System.out.print(i+" ");
      }
   }
   
   public static void main (String args[])
   {
      testGradesCemetech a=new testGradesCemetech();
      a.dispGrades();
   }
}
[/code]
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement