Grn Xtrm 84 Posting Pro in Training

That worked. Thanks a lot for your help.

Grn Xtrm 84 Posting Pro in Training

I know that the sort works properly, my problem lies with the binarySearch.

Grn Xtrm 84 Posting Pro in Training

I need to use the binary search on the sorted list, not the original list "mylist". I need to serch for a value in the sorted list. Try mixing up the numbers to really see the problem. Thanks for the reply.

Grn Xtrm 84 Posting Pro in Training

Hello friends. I'm working on a program to sort a list object using toArray, Arrays.sort, and Arrays.asList. The problem asks that I then apply Collections.binarySearch directly to the list object. I know what the problem is (which I have stated through comments in my code) but I don't know how to resolve it.
Here is my code :

import java.util.*;
//begin class PartC
public class PartC
{
	//begin main method
	public static void main(String args[])
	{
		//construct ArrayList object
		ArrayList<Integer> mylist = new ArrayList<Integer>();
		//ArrayList<Integer> newlist = new ArrayList<Integer>(mylist);
		//initialize scanner
		Scanner scan = new Scanner(System.in);
		//ask user how long the list will be
		System.out.println("Enter the number of values to be added to the list");
		int nums = scan.nextInt();
		//ask user to input each value separated by the enter key
		System.out.println("Input the values");
		//add all values to the list
		for(int index = 0; index<nums; ++index)
		{
			int input = scan.nextInt();
			mylist.add(input);
		}
		Object[] a = mylist.toArray();
		Arrays.sort(a);
		System.out.println(Arrays.asList(a));
		//not working because mylist is not sorted in ascending order
		//must make sorted list the parameter for the Collections.binarySearch
		System.out.println(mylist);
		System.out.println("Enter the value you want to search for");
		int searchValue = scan.nextInt();
		int where = Collections.binarySearch(mylist, searchValue);
		System.out.println("The value you searched for is at index " + where);
	}//terminates main method
}//terminates class PartC

Thanks for all your help.

Grn Xtrm 84 Posting Pro in Training

Great work with the Simpson quotes. That show is so funny and should be watched by all.

Grn Xtrm 84 Posting Pro in Training

Hi, I managed to resolve the problem by using

remove(0)

to remove the first element in the vector. Thanks again for taking the time to help me out.

Grn Xtrm 84 Posting Pro in Training

You can use

<center> text here </center>

open the tag at the start of the body and close the tag at the end of the body.

Grn Xtrm 84 Posting Pro in Training

I'm trying to use size() but I am getting incompatible type errors like these:
G:\Java 3\vector4.java:18: incompatible types
found : int
required: java.lang.Character
Character oper = opVect.size();
^
G:\Java 3\vector4.java:23: incompatible types
found : int
required: java.lang.Character
oper = opVect.size();
^
G:\Java 3\vector4.java:33: incompatible types
found : int
required: java.lang.String
String oper = opVect.size();
^
Any suggestions on how to resolve this?
Thanks alot for your time.

Grn Xtrm 84 Posting Pro in Training

You can achieve that by using a table with three rows. Set the top and bottom rows height to 10% and make the middle row 80%. However, this doesn't use divs and it looks like you want to. Sorry if this post is totally useless to you.

Grn Xtrm 84 Posting Pro in Training

The code segment I provided earlier is just to get the numbers into the list. Sorry, but I don't know that much about random numbers. Try searching on google.com.

Grn Xtrm 84 Posting Pro in Training

I would get rid of this

int numero;

I do input using the predefined scanner class

Scanner scan = new Scanner(System.in);
System.out.println("Enter how many numbers will be added");
int nums = scan.nextInt();
System.out.println("Input the numbers");
for(int index = 0; index<nums; ++index)
{
	int input = scan.nextInt();
	numero.add(input);
}

That's how I add user input numbers into the list.
By the way. Are you Italian?

Grn Xtrm 84 Posting Pro in Training

First you can have the user input the number of values to input into the data structure(arrays are a good choice). Then use a for loop to ask the user to put in each value.

Grn Xtrm 84 Posting Pro in Training

What line(s) of my program make the compiler think that I'm trying to access the 43rd element?
Also, I want to remove the last element of the vector to simulate a pop for stacks. How can I accomplish that?
Thanks for the reply.

Grn Xtrm 84 Posting Pro in Training

preorder = visit node, left, right
inorder = left, visit, right
postorder = left, right, visit

Repeat the process at each node.

Grn Xtrm 84 Posting Pro in Training

Hello, I'm facing another problem with vectors, this time with the problem of converting infix to postfix. The compile process completes, but I recieve an error after I enter the infix expression. Here is the exact error I recieve:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 43 >= 2
at java.util.Vector.removeElementAt(Vector.java:511)
at vector4.InToPost(vector4.java:22)
at vector4.main(vector4.java:79)

Process completed.

I don't really know what is wrong with my code and why I am recieving the error. Here is my code:

import java.util.*;
public class vector4
{
	public static String InToPost(String infixString)
	{
		//operator vector initialized
		Vector<Character> opVect = new Vector<Character>();
		//postfixString initialized as empty
		String postfixString = "";
		//scan infix strring and take appropriate action
		for(int index = 0; index<infixString.length(); ++index)
		{
			char chValue = infixString.charAt(index);
			if(chValue == '(')
				opVect.add('(');
			else if(chValue == ')')
			{
				Character oper = opVect.lastElement();
				while(!(oper.equals('(')) && !(opVect.isEmpty()))
				{
					postfixString += oper.charValue();
					opVect.removeElementAt(opVect.lastElement());
					oper = opVect.lastElement();
				}//end while loop
			opVect.removeElementAt(opVect.lastElement());
			}//end else if 
			else if(chValue == '+' || chValue == '-')
			{
				if(opVect.isEmpty()) //operatorStack is empty
				opVect.add(chValue);
				else //current operatorStack is not empty
				{
					Character oper = opVect.lastElement();
					while(!(opVect.isEmpty() || oper.equals(new Character('(')) || oper.equals(new Character(')'))))
					{
						opVect.removeElementAt(opVect.lastElement());
						postfixString += oper.charValue();
					}//ends while loop
				opVect.add(chValue);
				}//end else 
			}//end else if
			else if(chValue == '*' || chValue == '/')
			{
				if(opVect.isEmpty())
					opVect.add(chValue);
				else
				{
					Character oper = opVect.lastElement();
					while(!oper.equals(new Character('+')) && !oper.equals(new Character('-')) && !opVect.isEmpty())
					{
						opVect.removeElementAt(opVect.lastElement());
						postfixString += oper.charValue();
					}//end while loop
				opVect.add(chValue);
				}//end else
			}//end else if
			else
				postfixString += chValue;
		}//end for …
Grn Xtrm 84 Posting Pro in Training

Wow! I turns out he was right! I had a Vector.class file in the same directory. Deleting that solved the problem. Thanks again to both of you for the help.

Grn Xtrm 84 Posting Pro in Training

I am using Java 5.0.

You have other issues with using get(Object) calls that are not valid, but the declarations are fine.

Can you be more specific about my other issues? Thanks.

Grn Xtrm 84 Posting Pro in Training

Good suggestion, but that didn't work.

Grn Xtrm 84 Posting Pro in Training

Hello, I'm trying to write a program that evaluates a postfix expression using the vector class. I have done this successfully using stacks but I am experiencing trouble with vectors.
Here is the error message I am recieving:

I:\vector.java:26: type Vector does not take parameters
public static int evalPostfix(String str, Vector<Object> opndVect)
^
I:\vector.java:79: type Vector does not take parameters
Vector<Object> myvect = new Vector<Object>();
^
I:\vector.java:79: type Vector does not take parameters
Vector<Object> myvect = new Vector<Object>();
^
3 errors

Process completed.

Here is my code:

import java.util.*;
public class vector 
{
public static int convert(char chValue)
{
	switch(chValue)
	{
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default:
		{
			System.out.println("Error in evaluation");
			return -1;
		}//terminates default
	}//terminates switch
}//terminates text of convert method
//begin coding for evalPostfix method
public static int evalPostfix(String str, Vector<Object> opndVect)
{
	for(int index=0; index<str.length(); ++index)
	{
		//if current char is an integer
		char chValue=str.charAt(index);
		if('0'<=chValue && chValue<='9')
			//add the converted integer digit to the operand vector
		opndVect.add(convert(chValue));
		else
		{
			int opnd1=opndVect.get(opndVect.lastElement());
			opndVect.remove(opndVect.lastElement());
			int opnd2=opndVect.get(opndVect.lastElement());
			opndVect.remove(opndVect.lastElement());
			switch(chValue)
			{
				case '+':
				{
					int value=opnd1+opnd2;
					opndVect.add(value);
					break;
				}//end case +
				case '*':
				{
					int value=opnd1*opnd2;
					opndVect.add(value);
					break;
				}//end case *
				case '-':
				{
					int value=opnd1-opnd2;
					opndVect.add(value);
					break;
				}//end case - …
Grn Xtrm 84 Posting Pro in Training

Actually, a hoe is a gardening tool. But I guess that can't be what the original poster had in mind...

Grn Xtrm 84 Posting Pro in Training

You forgot to put 'neither should change names' on the poll. That's my vote.

Grn Xtrm 84 Posting Pro in Training

Do you have a mystack.h file implemented in the same folder as your main program?

Grn Xtrm 84 Posting Pro in Training

Turning Your Back on the Crowd EP by If But When.

Grn Xtrm 84 Posting Pro in Training

1NF- There must be a unique primary key and no repeating groups
2NF- No partial dependencies and in 1NF
3NF- No transitive dependencies and in 2NF

Grn Xtrm 84 Posting Pro in Training

I was able to compile and run the code successfully by separating all the files and creating an additional driver class. Thanks again for all the help.

Grn Xtrm 84 Posting Pro in Training

Good idea. Thanks so much for all your great advice.

Grn Xtrm 84 Posting Pro in Training

I know this is a beginner question but it is something that I have never had to do before. Is this the correct way to import the other classes?:

import Triangle.java.*;
import Isosceles.java.*;
import Equilateral.java.*;

I tried without the asterisks but recieved the same error message which reads:
F:\Java\GeometricObject.java:7: package Triangle.java does not exist
import Triangle.java.*;
^
F:\Java\GeometricObject.java:8: package Isosceles.java does not exist
import Isosceles.java.*;
^
F:\Java\GeometricObject.java:9: package Equilateral.java does not exist
import Equilateral.java.*;
^
I'm doing this in my GeometricObject file. Thanks again for all your help.

Grn Xtrm 84 Posting Pro in Training

I have rewritten my program with your suggestions but I am still getting the same error message.

abstract class GeometricObject
{
	//signature for perimeter method
	public abstract double perimeter();
//begin class Triangle
public class Triangle extends GeometricObject
{
	//explicit constructor
	public Triangle(double s1, double s2, double s3)
	{
		this.side1=s1;
		this.side2=s2;
		this.side3=s3;
	}//terminates constructor
	//perimeter method
	public double perimeter()
	{
		return side1+side2+side3;
	}//terminates perimeter method
	//local data fields
	private double side1;
	private double side2;
	private double side3;
}//terminates text of class Triangle
//begin class Isosceles
public class Isosceles extends Triangle
{
	//constructor
	public Isosceles( double EQside, double otherside)
	{
		super(EQside, EQside, otherside);
	}//terminates constructor
	//local data fields
	private double EQside;
	private double otherside;
}//terminates class Isosceles
//begin class Equilateral
public class Equilateral extends Isosceles
{
	//constructor
	public Equilateral(double side)
	{
		super(side, side);
	}//terminates constructor
	//local data field
	private double side;
}//terminates class Equilateral

For isosceles I used three parameters in the constructor call to match the Triangle constructor. For equilateral I used two parameters in the constructor call to match the isosceles constructor. I thought this was the right way to do it but I am obviously wrong. Thanks again for any help.

Grn Xtrm 84 Posting Pro in Training

Oh, right. So all of the constructor calls need to have the same number of parameters, but the parameters in the constructor definitions don't need to be the same in number, right? Thanks for your help, jasimp.

Grn Xtrm 84 Posting Pro in Training

Hello. I'm working on a class hierarchy that starts with an abstract class called GeometricObject. I want to use this class to create classes of different types of triangles. I want to these classes to inherit the perimeter method from the Triangle class. Here's what I have so far.

abstract class GeometricObject
{
    //signature for perimeter method
    public abstract double perimeter();

public class Triangle extends GeometricObject
{
    //explicit constructor
    public Triangle(double s1, double s2, double s3)
    {
        this.side1=s1;
        this.side2=s2;
        this.side3=s3;
    }//terminates constructor
    //perimeter method
    public double perimeter()
    {
        return side1+side2+side3;
    }//terminates perimeter method
    //local data fields
    private double side1;
    private double side2;
    private double side3;
}//terminates text of class Triangle
public class Isosceles extends Triangle
{
    //constructor
    public Isosceles( double EQside, double otherside)
    {
        super(EQside, otherside);
    }//terminates constructor
    //local data fields
    private double EQside;
    private double otherside;
}//terminates class Isosceles
public class Equilateral extends Isosceles
{
    //contructor
    public Equilateral(double side)
    {
        super(side);
    }//terminates constructor
    //local data fields
    private double side;
}//terminates class Equilateral

}//terminates class GeometricObject

I'm recieving the following error message:

F:\Java\GeometricObject.java:35: cannot reference this before supertype constructor has been called
        super(EQside, otherside);
        ^
F:\Java\GeometricObject.java:46: cannot reference this before supertype constructor has been called
        super(side);
        ^

There is obviously something wrong with the 2 lines starting with super, but I have not been able to figure it out.
Thanks to everyone in advance for any help.

Grn Xtrm 84 Posting Pro in Training

people have different taste/like.. maybe (for) other might like it..

Well said. Judging by the number of hits on the songs, it seems that many people like the music. Thanks again for the replies.

Grn Xtrm 84 Posting Pro in Training

no.. ahihihiihi:twisted:

"homecoming" by: hey monday

So you didn't like it? That's disappointing. Thanks for listening anyway.

Grn Xtrm 84 Posting Pro in Training

Off the top of my head, I'm pretty sure you must use:
<select>
<option> whatever you want in drop down menu</option>
repeat this for as many items you want in the drop down menu.
Be sure to enclose all of these items in option tags.
Also make sure to close your select tag.
Hope this examples helps.

<select name = "toppings">
		<option> Pepperoni </option>
		<option> Suasage </option>
		<option> Peppers </option>
		<option> Garlic</option>
</select>
Grn Xtrm 84 Posting Pro in Training

I'm currently learning from a book called Data Structures Using Java 5.0 by Nicholas J. DeLillo. It's a great book with lots of great examples.

Grn Xtrm 84 Posting Pro in Training

Sorry, I didn't mean that I would just give them the program. I was just saying that I have it correctly completed if anyone needs help. I respect the forum rules and would never go against the policy. I know that it is important for fellow viewers to solve their own problems by themselves with just a liitle help from the community. Sorry once again for the implications of my previous post.

Grn Xtrm 84 Posting Pro in Training

MS Access doesn't use quotes around numbers. Not sure about Oracle.

Grn Xtrm 84 Posting Pro in Training

If anyone needs help with this particular problem (converting infix to postfix and evaluating), send me a message. I have a working version of the program and I'd be glad to help.

Grn Xtrm 84 Posting Pro in Training

I don't but 3rd party accessories, they never seem to last for me. I stick with products made by Microsoft, Sony, etc.

Grn Xtrm 84 Posting Pro in Training

I don't watch anime, but anime video games are awesome. I love Tales of Symphonia, Tales of the Abyss, Tales of Vesperia, the Star Ocean series, and the Final Fantasy Series. Any one agree?

Grn Xtrm 84 Posting Pro in Training

your brother is hunk..

"Lucky" Mark & colbie

How'd you like the music?

Grn Xtrm 84 Posting Pro in Training

I couldn't agree with you more. I love to play RPG's, finish every single side-quest, and completely max out my characters.

Grn Xtrm 84 Posting Pro in Training

Hey, I always listen to the Bronx Underground band If But When (my brother is the bass player). They have a really unique pop-rock sound. Check out their debut EP on iTunes and check out the newly redesigned myspace page at www.myspace.com/ifbutwhen. By the way, sorry for the advertisement, but they really are awesome.

Grn Xtrm 84 Posting Pro in Training

Thanks for backing me up, verruckt24. It is good to see that not everyone in this forum is so cynical and suspicious. I made some ajustments to my program and got it to work. Thanks for your help.

Grn Xtrm 84 Posting Pro in Training

u need to implement the stack
then do precedence with switch cases
ill give more info once i get home, but at least show some code that you wrote not the code from your resource material form CD

I implemented the stack interface and the class containing all of the methods(pop, push, etc.) and I'm pretty sure there are no errors there. I wrote this code myself, I didn't copy it from a CD or website. Also, I know for a fact that converting from infix to postfix can be done without using a switch statement. Thanks for the reply though.

Grn Xtrm 84 Posting Pro in Training

Hello. I'm trying to write a program that will convert a user input infix expression into its postfix form. My current code is allowing the user to input a string, but it does nothing with the string. I'm fairly new to JAVA, thus I think I'm making a simple mistake in the main method. I'm using a generic class for a stacks implemented using arrays to store any data type. Thanks in advance for any help.

import java.io.*;
import java.util.*;
//begin coding for the stack interface
interface Stack<E>
{
    public boolean isEmpty();//tests is current stack is empty. Returns true if so, and false if not.
    public E top() throws StackException;//retrieves value at the top of the stack. Stack cannot be empty.
    public void push(E value) throws StackException;//pushes a value on the top of the stack. 
    public void pop() throws StackException;//removes a value from the top of the stack. Stack cannot be empty.
}//terminates coding of Stack interface

//begin coding for the objArrayStack class
class objArrayStack<E> implements Stack<E>
{
    //constructor
    public objArrayStack()
    {
        topValue=-1;
    }//terminates constructor
    public void push(E value)throws StackException
    {
        if(topValue<ArraySize-1)//currrent stack is not full
            {
                ++topValue;
                Info[topValue]=value;
            }//terminates if
        else //current stack is full
            throw new StackException("Error: Overflow");
    }//terminates push method
    public void pop() throws StackException
    {
        if(!isEmpty())//current stack is not empty
            --topValue;
        else //stack is empty
            throw new StackException("Error: Underflow");
    }//terminates pop method
    public boolean isEmpty()
    {
        return topValue==-1;
    }//terminates isEmpty method
    public E top() throws StackException
    {
        if(!isEmpty())//stack is not empty
            return (E)Info[topValue];
        else //stack …