Ugo Posada
Posts: 37
Nickname: binaryx
Registered: Dec, 2002
|
|
Re: Java Array Coursework
|
Posted: Jan 15, 2003 3:52 PM
|
|
> class Coursework > { > public static void main (String[ ] args) > { > > int arraySize; > > > System.out.print("Welcome to my program! This progam has > s been designed as coursework for my first year university > course."); > > > System.out.print("\n\n\n Please enter how many interger > r numbers you wish mathmatical equations to be preformed > on:"); > > > > arraySize = Easy.getInt(); >
Where did you get Easy from? You need to have an instance, unless that getInt() is a static method, however, I think you need to create an instance of the Easy class, you would do this by: Easy a = new Easy, and then call a.getInt().
> int length = arraySize length(); >
Dude, you are mad, why do you want to get the size of an int.
> int i=0; > > int array=0; > > int array = new int[arraySize]
I guess this is not what you want to do
you are probably trying to:
int[] array = new int[arraySize]; > > for (int i = 0; i<array length;i++); >
for (int i = 0; i<array.length;i++)
> { > > > System.out.print("\n\n\nPlease enter the numbers that > t you wish to input:"); > > > > array = Easy.getInt(); > } > char cal; > > > System.out.print("\n\n\nWhat Calculation would you > you like to preform?"); > System.out.print("\n\nA.The Area of a circle.\nB.The > .The Circumfrence of a circle\nC.The volume"); > > cal = Easy.getChar(); > > if cal=a
if (cal == "a") //I dont know very well how to compare chars
> { > for (int x=0; x<array length;x++) > > System.out.print("\n\nThe area of a circle with > with radius"+array"="+3.141*array^2) > > else cal=b;
else if (cal=="b")
> > for (int x=0; x<array length;x++) > System.out.print("\n\nThe circumfrence of a circle > rcle with radius" array"="6.282*array) > > else cal=c;
Same as before > > for (int x=0; x<array length;x++) > > System.out.print("\n\nThe Volume of a cube with > with sides" array"="array^3); > } > System.out.print("\n\n\n\nEnd of Program")) > } > } > > > > > this is my code in its entierity. i still get about 10 > errors which i have no idea what so ever to fix.i have > racked my brains, books and internet, but still nothing, > so if you are able to sort it out i will buy you a E-beer > for it.
To concatenate strings use the operator +, there are more mistakes in your code but I'm not gonna go trough it again. Just grab a book and start from the beginning dude. Keep the work up!.
|
|