943,470 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2245
  • Java RSS
Sep 25th, 2004
0

Y would something compile from a hard drive fine but from on a disk?

Expand Post »
Hi,
The following code compiles and runs fine from the hard drive but does not compile fine from a floppy disk. It gives me a cannot resolve symbol error for the DataSet dataSet = new DataSet(); line. Any ideas? The program is supposed to except user input for 4 integers and display the smallest and the largest of the 4. It does that fine from the hard drive.

class DataSet3
{
private int smallest;
private int largest;
private int value1;
private int value2;
private int value3;
private int value4;

//The constructor

public DataSet3()
{
smallest = 0;
largest = 0;
}

public void addValue(int whatvalue1, int whatvalue2, int whatvalue3, int whatvalue4)
{
value1 = whatvalue1;
value2 = whatvalue2;
value3 = whatvalue3;
value4 = whatvalue4;
}

public int getSmallest()
{
int min12 = Math.min(value1, value2);
int min34 = Math.min(value3, value4);

return Math.min(min12, min34);
}

public int getLargest()
{
int max12 = Math.max(value1, value2);
int max34 = Math.max(value3, value4);

return Math.max(max12, max34);

}
}


import javax.swing.JOptionPane;

class DataSetTest3
{
public static void main(String[] args)
{

int number1 = 0, number2 = 0, number3 = 0, number4 = 0;
String value=" ";

value = JOptionPane.showInputDialog("Please Enter Number 1:");
number1 = Integer.parseInt(value);

value = JOptionPane.showInputDialog("Please Enter Number 2:");
number2 = Integer.parseInt(value);

value = JOptionPane.showInputDialog("Please Enter Number 3:");
number3 = Integer.parseInt(value);

value = JOptionPane.showInputDialog("Please Enter Number 4:");
number4 = Integer.parseInt(value);

DataSet dataSet = new DataSet();
dataSet.addValue(1, number1);
dataSet.addValue(2, number2);
dataSet.addValue(3, number3);
dataSet.addValue(4, number4);

System.out.println("The smallest number is " +dataSet.getSmallest());
System.out.println("The largest number is " +dataSet.getLargest());

System.exit(0);

}
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KCC1982 is offline Offline
2 posts
since Sep 2004
Sep 27th, 2004
0

Re: Y would something compile from a hard drive fine but from on a disk?

Where is your Dataset() method defined? Are you including this class on your floppy? I ask because I don't see it (Dataset) defined, or included in your code above.

I assume you are compiling on a different PC?
Reputation Points: 11
Solved Threads: 1
Junior Poster in Training
jerbo is offline Offline
84 posts
since Sep 2004
Oct 8th, 2004
0

Re: Y would something compile from a hard drive fine but from on a disk?

It looks like you renamed the class. Either change all references to DataSet to DataSet3 -OR- change all DataSet3 to DataSet

Java Syntax (Toggle Plain Text)
  1. //Make it like this:
  2. class DataSet
  3. {
  4. public DataSet()
  5. .....
  6.  
  7. }


Quote originally posted by KCC1982 ...
class DataSet3
{
public DataSet3()
.....

}
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Wait while processing Note
Next Thread in Java Forum Timeline: casting error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC