0

I have this program that I am working on that I am trying to insert user entered integers till a "-1" is detected and it will stop inserting the integers into the Tree and print it out inOrder.

I am geting 2 errors:

File: S:\makeup1.java [line: 9]
Error: S:\makeup1.java:9: cannot find symbol
symbol : class Tree
location: class makeup1

File: S:\makeup1.java [line: 9]
Error: S:\makeup1.java:9: cannot find symbol
symbol : class Tree
location: class makeup1

import java.util.Scanner;
import java.io.*;

public class makeup1{
  
    public static void main(String [] args){
    
    int n;
    Tree t = new Tree();
    Scanner scanner = new Scanner(System.in);
    
    while(n!=-1){
      System.out.println("input integer into tree: ");
      n = scanner.nextInt();
      insert(t,n);
    }
   
  }
   public static class tree{
    public int value;
    public tree right;
    public tree left;
    public tree(int V, tree L, tree R){
      {
        value = V;
        left = L;
        right = R;
      }
    }
  }
   
   public static tree insert(tree t, int i){
     if(t==null){
      return null; 
     }
     if(t.left!=null){
       insert(t.left, i);
     }
     else if(t.right!=null){
       insert(t.right, i);
     }
   }
   public static tree treesort(tree t){
     if(t==null){
       return null;
     }
     if(!(t.left==null)){
       return t.left;
     }
     return t.right;
   }

}

Can anyone help me out?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by mellowmike
0

Hello.
The compiler tells you that it doesn't understand what is Tree[/]. To fix the problem you should either add import for Tree data type, or declare this data type in your makeup1 class.

0

You have Tree t = new Tree(); but the class you defined is "tree" in lower case. Change the line to lower case "tree", or change the class to upper case.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.