Jump to content


Jframe Help


  • Please log in to reply
No replies to this topic

#1 Erex

Erex

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 03 April 2012 - 09:43 PM

I need help I'm trying to extend this into a JFrame, with buttons, and text fields but I can't manage to do so. Can ya'll help me?

import java.util.Scanner;
public class TesterClass {
//Program is not distinguishing between the students
//And is not calculating the class average or raised class average.
	
public static void main(String[] args) {
	public AveragingGrades()
 {
	
int allTotal = 0;
int totalLowest = 0;
int studTotal = 0;
int studRaiseTotal = 0;
int numScores = 0;1
int lowest = 0;
int students = 0;
double studRaiseAve = 0;
double studNormAve = 0;
double allAve = 0;
double allRaiseAve = 0;
	
Scanner testScan = new Scanner(System.in);
System.out.println("How many students are you entering scores for?"); 
students = testScan.nextInt();
System.out.println("How many scores do you need to enter for each student?");
numScores = testScan.nextInt();
int[] studentsArray = new int[students];	
int[] scoresArray = new int[numScores];
for(int bigTemp: studentsArray){ //determines how many scores are entered for each student
	
	
	
for(int temp: scoresArray) //determines the total and average scores for each student
{ 
			
		int n = bigTemp+1;
		System.out.println("Enter a score for student number: "+n);
		temp = testScan.nextInt();
		studTotal += temp;
			
			if(temp<lowest)
			{
			lowest = temp;
			
			
			 if(numScores>1);{
			 studRaiseTotal = studTotal-lowest;
			 studRaiseAve = (double)(studRaiseTotal/(numScores-1)); 
			 }
						 
			 if(numScores==1){
			 studRaiseTotal = studTotal;
			 studRaiseAve = (double) (studRaiseTotal/numScores);
			 }
			
			}
}			
			studNormAve = (double)(studTotal/numScores);
			System.out.println("Here is the student's total test scores.");
   		 	System.out.println(studTotal);
			System.out.println("Here is the student's average test scores.");
			System.out.println(studNormAve);
			System.out.println("Here is the student's raised score.");
			System.out.println(studRaiseAve);
			
			if (studNormAve>=70){
   		 		System.out.println("This student passes.");
				System.out.println("The student's average test score is: "+studNormAve);
   		 	}
	
   		 	else{
   		 		System.out.println("This student fails.");
				System.out.println("The student's average test score is: "+studNormAve);
   		 	}
}
allTotal += studTotal;
totalLowest += lowest;
	
System.out.println("Testing for the total: "+allTotal); 
System.out.println("Testing for the lowest: "+lowest); 
System.out.println("Testing for the total lowest: "+totalLowest);
	
allAve = (double)(allTotal/(students*numScores));
System.out.println("Here is the class's average.");
System.out.println(allAve);
	
allRaiseAve = (double)((allTotal-totalLowest)/(students*numScores));
System.out.println("Here is the raised class average.");
System.out.println(allRaiseAve);
	
}
}