7 errors found:
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 62]
Error: Min cannot be resolved to a variable
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 65]
Error: mode cannot be resolved to a variable
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 68]
Error: Max cannot be resolved to a variable
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 71]
Error: median cannot be resolved to a variable
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 74]
Error: average cannot be resolved to a variable
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 86]
Error: dev cannot be resolved to a variable
File: C:\Users\parents\Desktop\Colton\Science fair\MainAsd.java [line: 222]
Error: Syntax error, insert "}" to complete ClassBody
ill color them in
*****************************************************************************************
import java.awt.*;
import javax.swing.*;
import java.util.Arrays;
public class MainAsd
{
public static int getMaximum(int[] Random)
{
int max=0;
int[] toReturn = new int[Random.length+1];
for (int i = 0; i < Random.length; i++)
{
if ( Random[i] > toReturn[0])
{
toReturn[0] = Random[i];
max = i;
}
}
return max;
}
//starts here
public class DataOutput extends JFrame
{
private static final long serialVersionUID = -4480786588092262886L;
JLabel Mean2;
JLabel Median2;
JLabel Mode2;
JLabel Min2;
JLabel max2;
JTextField min1;
JTextField mode1;
JTextField max1;
JTextField median1;
JTextField Mean1;
JLabel OutputData1;
JButton Ok;
JLabel SD;
JTextField SD1;
public DataOutput() {
DataOutputLayout customLayout = new DataOutputLayout();
getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 14));
getContentPane().setLayout(customLayout);
Mean2 = new JLabel("Mean");
getContentPane().add(Mean2);
Median2 = new JLabel("Median");
getContentPane().add(Median2);
Mode2 = new JLabel("Mode");
getContentPane().add(Mode2);
Min2 = new JLabel("Minnimum");
getContentPane().add(Min2);
max2 = new JLabel("Maximum");
getContentPane().add(max2);
[COLOR="yellow"] min1 = new JTextField(Min);[/COLOR]
getContentPane().add(min1);
[COLOR="yellow"] mode1 = new JTextField(mode);[/COLOR]
getContentPane().add(mode1);
[COLOR="yellow"]max1 = new JTextField(Max);[/COLOR]
getContentPane().add(max1);
[COLOR="yellow"] median1 = new JTextField(median);[/COLOR]
getContentPane().add(median1);
[COLOR="yellow"]Mean1 = new JTextField(average);[/COLOR]
getContentPane().add(Mean1);
OutputData1 = new JLabel(" OutputData");
getContentPane().add(OutputData1);
Ok = new JButton("Ok");
getContentPane().add(Ok);
SD = new JLabel("Standard Deviation");
getContentPane().add(SD);
[COLOR="yellow"]SD1 = new JTextField(dev);[/COLOR]
getContentPane().add(SD1);
pack();
setVisible(true);
}
}
class DataOutputLayout implements LayoutManager {
public DataOutputLayout() {
}
public void addLayoutComponent(String name, Component comp) {
}
public void removeLayoutComponent(Component comp) {
}
public Dimension preferredLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);
Insets insets = parent.getInsets();
dim.width = 175 + insets.left + insets.right;
dim.height = 350 + insets.top + insets.bottom;
return dim;
}
public Dimension minimumLayoutSize(Container parent) {
Dimension dim = new Dimension(0, 0);
return dim;
}
public void layoutContainer(Container parent) {
Insets insets = parent.getInsets();
Component c;
c = parent.getComponent(0);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+96,72,24);}
c = parent.getComponent(1);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+128,72,24);}
c = parent.getComponent(2);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+160,72,24);}
c = parent.getComponent(3);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+224,72,24);}
c = parent.getComponent(4);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+192,72,24);}
c = parent.getComponent(5);
if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+224,72,24); }
c = parent.getComponent(6);
if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+160,72,24); }
c = parent.getComponent(7);
if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+192,72,24); }
c = parent.getComponent(8);
if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+128,72,24); }
c = parent.getComponent(9);
if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+96,72,24);}
c = parent.getComponent(10);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+16,152,64);}
c = parent.getComponent(11);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+288,152,48); }
c = parent.getComponent(12);
if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+256,72,24);}
c = parent.getComponent(13);
if (c.isVisible()) {c.setBounds(insets.left+88,insets.top+256,72,24); }
}
}
//ends here
public static void main(String[] args)
{
int value = 100000; //amout of tested numbers
int value2 = 10; //range of tested numbers (maximum value possible)
int[]Counter = new int [value+1];
int[] Random;
Random = new int[value+1];
int count = 0;
double average = 0;
int Max = value2;
int Min = 0;
int sum = 0;
int number = 0;
double median = 0;
int mode = 0;
double dev = 0;
double acc = 0;
for (count = 0; count < value; count++)
{
number = (int)(Math.random()*value2+1);
Random[count] = number;
sum = sum + number;
}
average = (double)sum/(double)value;
System.out.println(value+" randomly generated numbers from 0 to "+value2);
System.out.println("In Ascending Order:");
Arrays.sort(Random);
for (count = 0; count < value; count++)
{
//comenmt out
// System.out.println(Random[count]);
while(Random[count]>Max)
Max=Random[count];
while(Random[count]<Min)
Min=Random[count];
median=Random[value/2];
}
for (int k = 0; k < value; k++)
{
Counter[Random[k]] =Counter[Random[k]]+1;
}
for (int k = 0; k < value; k++)
{
acc = acc + (Random[k]-average)*(Random[k]-average);
}
average= average-.5;
dev = Math.sqrt(acc/value);
mode=getMaximum(Counter);
System.out.println("The highest number is " + Max);
System.out.println("The lowest number is " + Min);
System.out.println("The median is "+median+".");
System.out.println("The average is: " +average);
System.out.println("The mode is "+mode);
System.out.println("The standard deviation is "+dev);
new MainAsd().startStuff();
}
public void startStuff(){
new DataOutput();
[COLOR="yellow"] }[/COLOR]


Sign In
Create Account


Back to top









