shastenm76

Untitled

Mar 6th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. // 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. //
  2.  
  3. // StatCalc.java //
  4.  
  5. /*
  6. * To change this license header, choose License Headers in Project Properties.
  7. * To change this template file, choose Tools | Templates
  8. * and open the template in the editor.
  9. */
  10. package statcalc;
  11.  
  12. /**
  13. *
  14. * @author shasten
  15. */
  16. public class StatCalc {
  17.  
  18. private int count;
  19. private double sum;
  20. private double squareSum;
  21. private double mean;
  22. private double StandardDeviation;
  23.  
  24. public void enter(double num) {
  25. count++;
  26. sum += num;
  27. squareSum += num*num;
  28.  
  29.  
  30. }
  31.  
  32. /**
  33. * @param args the command line arguments
  34. */
  35. public static void main(String[] args) {
  36. // TODO code application logic here
  37. }
  38.  
  39. /**
  40. * @return the count
  41. */
  42. public int getCount() {
  43. return count;
  44. }
  45.  
  46. /**
  47. * @return the sum
  48. */
  49. public double getSum() {
  50. return sum;
  51. }
  52.  
  53. /**
  54. * @return the mean
  55. */
  56. public double getMean() {
  57. return sum / count;
  58. }
  59.  
  60. /**
  61. * @return the StandardDeviation
  62. */
  63. public double getStandardDeviation() {
  64. double mean = getMean();
  65. return Math.sqrt(squareSum/count - mean*mean);
  66. }
  67.  
  68. }
  69.  
  70. // MyStatCalc.java
  71.  
  72. /*
  73. * To change this license header, choose License Headers in Project Properties.
  74. * To change this template file, choose Tools | Templates
  75. * and open the template in the editor.
  76. */
  77. package statcalc;
  78.  
  79. /**
  80. *
  81. * @author live
  82. */
  83. public class MyStatCalc {
  84.  
  85. public static void main(String[] args) {
  86.  
  87. int[] nums = {5, 7, 12, 23, 3, 2, 8, 14, 10, 5, 9, 13};
  88.  
  89. StatCalc myStatCalc;
  90. myStatCalc = new StatCalc();
  91.  
  92.  
  93. for (int x : nums)
  94. myStatCalc.enter(x);
  95.  
  96.  
  97. System.out.println("The count is " + myStatCalc.getCount());
  98. System.out.println("The mean is " + myStatCalc.getMean());
  99. System.out.println("The Standard Deviation is " + myStatCalc.getStandardDeviation());
  100.  
  101. }
  102. }
  103.  
  104. Everything builds correctly, but I can't seem to fix this error when I actually run the program.
  105.  
  106. Error: Could not find or load main class StatCalc
  107. Caused by: java.lang.NoClassDefFoundError: statcalc/StatCalc (wrong name: StatCalc)
  108.  
  109. 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