Jump to content

cannot resolve symbol

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1
dvdtomkins

dvdtomkins

    Newbie

  • Members
  • PipPip
  • 16 posts
I can't resolve this problem when I compile I get two errors that say cannot resovle symbol but I can't figure out why could you help me maybe.



import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.IOException;


public class bank2

{

        BufferedReader keyboardReader;



        private final String name="Daniel Kulla";

        private final int savAccountNumber=12345678;

        private final int cheqAccountNumber=87654321;

        private final int credAccountNumber=45678910;

        

        private String input;

        private char input2;

        private double input3=0.0;



        private double savings=0.0;

        private double credit=0.0;

        private double cheque=0.0;

 


	private double rateSav= 0.7;

	private double rateCred= 7.2;

	private double rateCheq = 0.0;




   public char accountInput()

     {

      System.out.println("Enter account type: s=savings c=cheque d=credit");



      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


      try

       {

        input = br.readLine();

       }

      catch(IOException ioe)

       {

        ioe.printStackTrace();

       }

       input2 = input.charAt(0);


        return input2;

      }//end of char accountInput()


   public char accountAction()

     {

      System.out.println("Enter an action: d=deposit w=withdraw i=information");



      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


      try

       {

        input = br.readLine();

       }

      catch(IOException ioe)

       {

        ioe.printStackTrace();

       }

       input2 = input.charAt(0);



        return input2;

      }//end of char accountAction()



   public double inputFloat()

     {

            System.out.println("Enter Amount: ");

            input3 = new Double(keyboardReader.readLine()).doubleValue();



        return input3;

      }//end of inputFloat()



public void program()

     {



while(input2 != 'e')

  {

   switch(input2)

    {


      case 's':

        System.out.println("You are in your savings account");

        accountAction();


     while(input2 != 'e')

      {


         switch(input2)

        {

            case 'd':

                  savings += inputFloat();

                break;


            case 'w':

                  savings -= inputFloat();

                break;


            case 'i':

                  System.out.println("Account number: "+savAccountNumber);

	          System.out.println("Account name: "+name);

	          System.out.println("Balance: "+savings);

                  System.out.println("Intrest rate: "+rateSav);


                break;


            default:

                  System.out.println("Invalid input");

                break;




         }//end of switch 1


     accountInput();


       }//end of inner while

      break;


            case 'c':

                 System.out.println("You are in your cheque account");

                 accountAction();


	       while(input2 != 'e')

	        {


	           switch(input2)

	          {


            case 'd':

                  cheque += inputFloat();

                break;


            case 'w':

                  cheque -= inputFloat();

                break;


            case 'i':

                  System.out.println("Account number: "+cheqAccountNumber);

	          System.out.println("Account name: "+name);

	          System.out.println("Balance: "+cheque);

                  System.out.println("Intrest rate: "+rateCred);


                break;


            default:

                  System.out.println("Invalid input");

                break;




             }//end of switch 1


            accountInput();


          }//end of inner while

      break;


            case 'd':

                 System.out.println("You are in your credit account");

                 accountAction();


	       while(input2 != 'e')

	        {


	           switch(input2)

	          {


            case 'd':

                  credit += inputFloat();

                break;


            case 'w':

                  credit -= inputFloat();

                break;


            case 'i':

                  System.out.println("Account number: "+credAccountNumber);

	          System.out.println("Account name: "+name);

	          System.out.println("Balance: "+credit);

                  System.out.println("Intrest rate: "+rateCheq);


                break;


            default:

                  System.out.println("Invalid input");

                break;




           }//end of switch 1


         accountInput();


       }//end of inner while


      break;


      default:

            System.out.println("Invalid input");

	  break;



    }//end of outer switch

  accountInput();



 }//end of outer while



}// end of program()





public static void main(String[] args)

   {



       new accountInput();

       new program();



   }//end of main

}//end of class bank2









#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What are the exact error messages?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
dvdtomkins

dvdtomkins

    Newbie

  • Members
  • PipPip
  • 16 posts
Here is the exact error message:



bank2.java:231: cannot resolve symbol

symbol  :  class accountInput

location :  class bank2

          new accountInput();

                ^


bank2.java:232:  cannot resolve symbol

symbol   : class  program

location :  class bank2

         new program():

               ^

2 errors



Edited by dvdtomkins, 16 July 2008 - 01:28 AM.
the little arrows were not in the right place


#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
The new operator is used to create instances of classes. accountInput and program are defined as functions.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
dvdtomkins

dvdtomkins

    Newbie

  • Members
  • PipPip
  • 16 posts
I took the new's away now I'm getting these errors:
Click here to see the errors

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
try bank2.accountInput() and bank2.program()
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
dvdtomkins

dvdtomkins

    Newbie

  • Members
  • PipPip
  • 16 posts
I tried that but I get the same error.
Click here to see the errors(sorry about the ads but it's a free web host)

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Actually, you may need to create an instance of bank2.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
dvdtomkins

dvdtomkins

    Newbie

  • Members
  • PipPip
  • 16 posts
How do I go about doing that.

#10
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Use the new operator.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#11
dvdtomkins

dvdtomkins

    Newbie

  • Members
  • PipPip
  • 16 posts
Ive managed to get it compile with this code, but when I run the program I get this error:

C:\dan\dan2>java -cp . bank2
Enter account type: s=savings c=cheque d=credit
s
You are in your savings account
Enter an action: d=deposit w=withdraw i=information
d
Enter Amount:
Exception in thread "main" java.lang.NullPointerException
at bank2.inputFloat(bank2.java:81)
at bank2.program(bank2.java:112)
at bank2.main(bank2.java:239)

C:\dan\dan2>

Here's the code:


import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.IOException;


public class bank2

{

        BufferedReader keyboardReader;



        private final String name="Daniel Kulla";

        private final int savAccountNumber=12345678;

        private final int cheqAccountNumber=87654321;

        private final int credAccountNumber=45678910;


        private String input;

        private char input2;




        private double savings=0.0;

        private double credit=0.0;

        private double cheque=0.0;



	private double rateSav= 0.7;

	private double rateCred= 7.2;

	private double rateCheq = 0.0;




   public char accountInput()

     {

      System.out.println("Enter account type: s=savings c=cheque d=credit");



      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


      try

       {

        input = br.readLine();

       }

      catch(IOException ioe)

       {

        ioe.printStackTrace();

       }

       input2 = input.charAt(0);


        return input2;

      }//end of char accountInput()


   public char accountAction()

     {

      System.out.println("Enter an action: d=deposit w=withdraw i=information");



      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


      try

       {

        input = br.readLine();

       }

      catch(IOException ioe)

       {

        ioe.printStackTrace();

       }

       input2 = input.charAt(0);



        return input2;

      }//end of char accountAction()



   public double inputFloat()

     {

            double input3=0.0;

            System.out.println("Enter Amount: ");


        try

        {

            input3 = new Double(this.keyboardReader.readLine()).doubleValue();

        }

        catch (IOException ioe)

        {

            System.out.println("There was a problem reading the input from the keyboard");

            ioe.printStackTrace();

        }


        return input3;

      }//end of inputFloat()



public void program()

     {

      accountInput();


while(input2 != 'e')

  {

   switch(input2)

    {


      case 's':

        System.out.println("You are in your savings account");

        accountAction();


     while(input2 != 'e')

      {


         switch(input2)

        {

            case 'd':

                  savings += inputFloat();

                break;


            case 'w':

                  savings -= inputFloat();

                break;


            case 'i':

                  System.out.println("Account number: "+savAccountNumber);

	          System.out.println("Account name: "+name);

	          System.out.println("Balance: "+savings);

                  System.out.println("Intrest rate: "+rateSav);


                break;


            default:

                  System.out.println("Invalid input");

                break;




         }//end of switch 1


     accountInput();


       }//end of inner while

      break;


            case 'c':

                 System.out.println("You are in your cheque account");

                 accountAction();


	       while(input2 != 'e')

	        {


	           switch(input2)

	          {


            case 'd':

                  cheque += inputFloat();

                break;


            case 'w':

                  cheque -= inputFloat();

                break;


            case 'i':

                  System.out.println("Account number: "+cheqAccountNumber);

	          System.out.println("Account name: "+name);

	          System.out.println("Balance: "+cheque);

                  System.out.println("Intrest rate: "+rateCred);


                break;


            default:

                  System.out.println("Invalid input");

                break;




             }//end of switch 2


            accountInput();


          }//end of inner while

      break;


            case 'd':

                 System.out.println("You are in your credit account");

                 accountAction();


	       while(input2 != 'e')

	        {


	           switch(input2)

	          {


            case 'd':

                  credit += inputFloat();

                break;


            case 'w':

                  credit -= inputFloat();

                break;


            case 'i':

                  System.out.println("Account number: "+credAccountNumber);

	          System.out.println("Account name: "+name);

	          System.out.println("Balance: "+credit);

                  System.out.println("Intrest rate: "+rateCheq);


                break;


            default:

                  System.out.println("Invalid input");

                break;




           }//end of switch 3


         accountInput();


       }//end of inner while


      break;


      default:

            System.out.println("Invalid input");

	  break;



    }//end of outer switch

  accountInput();



 }//end of outer while



}// end of program()





public static void main(String[] args)

   {


       new bank2().program();



   }//end of main

}//end of class bank2



#12
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
null entry cannot be converted to double.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog