Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I have a problem that I am trying to solve except I don't know much about Java, and I only have until tonight to solve this problem. Any help I can get is greatly appreciated. //
- // StatCalc.java //
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package statcalc;
- /**
- *
- * @author shasten
- */
- public class StatCalc {
- private int count;
- private double sum;
- private double squareSum;
- private double mean;
- private double StandardDeviation;
- public void enter(double num) {
- count++;
- sum += num;
- squareSum += num*num;
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- }
- /**
- * @return the count
- */
- public int getCount() {
- return count;
- }
- /**
- * @return the sum
- */
- public double getSum() {
- return sum;
- }
- /**
- * @return the mean
- */
- public double getMean() {
- return sum / count;
- }
- /**
- * @return the StandardDeviation
- */
- public double getStandardDeviation() {
- double mean = getMean();
- return Math.sqrt(squareSum/count - mean*mean);
- }
- }
- // MyStatCalc.java
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package statcalc;
- /**
- *
- * @author live
- */
- public class MyStatCalc {
- public static void main(String[] args) {
- int[] nums = {5, 7, 12, 23, 3, 2, 8, 14, 10, 5, 9, 13};
- StatCalc myStatCalc;
- myStatCalc = new StatCalc();
- for (int x : nums)
- myStatCalc.enter(x);
- System.out.println("The count is " + myStatCalc.getCount());
- System.out.println("The mean is " + myStatCalc.getMean());
- System.out.println("The Standard Deviation is " + myStatCalc.getStandardDeviation());
- }
- }
- Everything builds correctly, but I can't seem to fix this error when I actually run the program.
- Error: Could not find or load main class StatCalc
- Caused by: java.lang.NoClassDefFoundError: statcalc/StatCalc (wrong name: StatCalc)
- I've also tried including TextIO.java in the mix, but that hasn't seemed to do anything for me. I'm using NetBeans10.
Advertisement
Add Comment
Please, Sign In to add comment