Hi guys,
This is my first post and basically i require some help editing my current code to help display number of students with a mark of 40 or above specifically. And also i am having difficulty generating a average i thought i done it but it remained constant a 4.0 with every test. This work is on going so i will be constantly updating the page each time i run into more troubles. Thanks guys below is a copy of my code and how far i got...
package histogram1;
import java.util.Scanner;
public class Histogram1
public static void main(String[] args)
Scanner MK = new Scanner(System.in);
int[] ranges = {0,29,39,69,100 };
int[] inRange = new int[ranges.length - 1];
int mark;
int largest = 0;
int smallest = 0;
do
System.out.println("Enter Mark:");
mark = MK.nextInt();
for (int j=1 ; j<ranges.length ; j++)
if (ranges[j-1] <= mark && mark <= ranges[j])
inRange[j-1]++;
break;
if (mark < smallest)
smallest = mark;
else if (mark > largest)
largest = mark;
while (mark >= 0);
System.out.println("Among all your numbers, " + smallest + " is the smallest " + "and " + largest + " is the largest number.");
for (int j = 0; j < k; j++)
mark += ranges.length;
double avg = (double) (mark) / k;
System.out.println("average is " + avg);
int average;
String s = "The number of students that have scored between %d and %d is : ";
int k = 0;
for (int i=0 ; i<ranges.length - 1 ; i++)
System.out.print(String.format(s,ranges[i] + k,ranges[i + 1]));
for (int r = 0; r<inRange[i] ; r++)
System.out.print("*");
System.out.println();
k = 1;
MK.close();