Skip to main content
formatted the code
Source Link
PM 77-1
  • 13.4k
  • 21
  • 73
  • 118

I am trying to get the minimum value from an array that I have set up but it keeps returning a value of 00?!?! ` import java.util.Scanner; public class ACTScoring {

import java.util.Scanner; public class ACTScoring { /**   * Stack Underflow   * 11/17/15   * ACT Scores are pretty neat   */  public static void main(String[] args) {   int[] score = new int[12];   Scanner inputTest = new Scanner(System.in);   int totalScores = 0;   double average = 0.0;   int high = score[0];   int low = score[0];     for (int count = 0; count < score.length; count++){   System.out.println("Please Enter in the score: ");   score[count] = inputTest.nextInt();     }   for (int count = 0; count < score.length; count++){   totalScores = totalScores + score[count];     if(score[count]>high)   high=score[count];   //low keeps outputting 0   else if (score[count]<low)   low=score[count];     average = (totalScores*1.0) / score.length;   }     System.out.println("Your average score is: " + average);   System.out.println("Your Highest Score was: " +high);   System.out.println("Your lowest Score was: "+ low); }  } 

} `

I am trying to get the minimum value from an array that I have set up but it keeps returning a value of 0?!?! ` import java.util.Scanner; public class ACTScoring {

/** * Stack Underflow * 11/17/15 * ACT Scores are pretty neat */ public static void main(String[] args) { int[] score = new int[12]; Scanner inputTest = new Scanner(System.in); int totalScores = 0; double average = 0.0; int high = score[0]; int low = score[0]; for (int count = 0; count < score.length; count++){ System.out.println("Please Enter in the score: "); score[count] = inputTest.nextInt(); } for (int count = 0; count < score.length; count++){ totalScores = totalScores + score[count]; if(score[count]>high) high=score[count]; //low keeps outputting 0 else if (score[count]<low) low=score[count]; average = (totalScores*1.0) / score.length; } System.out.println("Your average score is: " + average); System.out.println("Your Highest Score was: " +high); System.out.println("Your lowest Score was: "+ low); } 

} `

I am trying to get the minimum value from an array that I have set up but it keeps returning a value of 0?!?!

import java.util.Scanner; public class ACTScoring { /**   * Stack Underflow   * 11/17/15   * ACT Scores are pretty neat   */  public static void main(String[] args) {   int[] score = new int[12];   Scanner inputTest = new Scanner(System.in);   int totalScores = 0;   double average = 0.0;   int high = score[0];   int low = score[0];     for (int count = 0; count < score.length; count++){   System.out.println("Please Enter in the score: ");   score[count] = inputTest.nextInt();     }   for (int count = 0; count < score.length; count++){   totalScores = totalScores + score[count];     if(score[count]>high)   high=score[count];   //low keeps outputting 0   else if (score[count]<low)   low=score[count];     average = (totalScores*1.0) / score.length;   }     System.out.println("Your average score is: " + average);   System.out.println("Your Highest Score was: " +high);   System.out.println("Your lowest Score was: "+ low); }  } 
Source Link

Java help, minimum value in an array

I am trying to get the minimum value from an array that I have set up but it keeps returning a value of 0?!?! ` import java.util.Scanner; public class ACTScoring {

/** * Stack Underflow * 11/17/15 * ACT Scores are pretty neat */ public static void main(String[] args) { int[] score = new int[12]; Scanner inputTest = new Scanner(System.in); int totalScores = 0; double average = 0.0; int high = score[0]; int low = score[0]; for (int count = 0; count < score.length; count++){ System.out.println("Please Enter in the score: "); score[count] = inputTest.nextInt(); } for (int count = 0; count < score.length; count++){ totalScores = totalScores + score[count]; if(score[count]>high) high=score[count]; //low keeps outputting 0 else if (score[count]<low) low=score[count]; average = (totalScores*1.0) / score.length; } System.out.println("Your average score is: " + average); System.out.println("Your Highest Score was: " +high); System.out.println("Your lowest Score was: "+ low); } 

} `