PostsChallengesPortalsAuthorsBooks
Sign Up
Log In
Posts
Challenges
Portals
Authors
Books
beta
Sign Up
Search
Follow
kyang
MHS student
1 Post • 1 Follower • 1 Following
Posts
Likes
Challenges
Books
Challenge
Computer Coding the world
Create a "computer code" for something, either life, writing, philosoph, school. An word count, mine will be short. Enjoy!
kyang in Technology

Calculating School Test Score Statistics (School Computer Code)

/**************************************************

*File Name: FloatStats

*Purpose: Calculate a series of statistics using user defined float values

*Programmer: Kevin Yang

*Last Updated Date: 11/07/19

*************************************************/

import javax.swing.JOptionPane;

public class FloatStats {

public static void main(String[] args) {

JOptionPane.showMessageDialog(null, “After you enter all your test grades, enter ‘a.’”);

String userNum = JOptionPane.showInputDialog(“Enter your test grade.”);

int counter = 0;

float sum = 0;

float average = 0;

float biggestNum = 0;

float smallestNum = 0;

float num = 0;

if (!(userNum.equals(“a”))) {

num = Float.parseFloat(userNum);

biggestNum = num;

smallestNum = num;

}

while (!(userNum.equals(“a”))) {

sum = sum + num;

userNum = JOptionPane.showInputDialog(“Enter another test grade.”);

counter += 1;

average = sum / counter;

if (!(userNum.equals(“a”))) {

num = Float.parseFloat(userNum);

if (num >= biggestNum)

biggestNum = num;

if (num <= smallestNum)

smallestNum = num;

}

}

JOptionPane.showMessageDialog(null, “Your average test score is ” + average);

JOptionPane.showMessageDialog(null, “Your highest test score is ” + biggestNum);

JOptionPane.showMessageDialog(null, “Your lowest test score is ” + smallestNum);

JOptionPane.showMessageDialog(null, “The range between your highest and lowest test score is ” + (biggestNum - smallestNum));

}

}