Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Cannot Find Symbol Compiling Error

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Cannot Find Symbol Compiling Error

    So I am making a bill class, which will (hopefully) work with a Money and Date class.
    So far (I only tested a little code so far) two of my method are getting a Cannot find symbol error. I have only seen this error one other time and I cannot remember how I solved it. The two lines with the obnoxious amount of stars are the placed where the code appears.

    /**
     * Kristen Watson
     * CSS162A: Homework 3 
     * 
     * Description:
     */
    public class Bill{
     
        //Variables/Data
        Money amount;
        Date dueDate;
        Date paidDate;
        String originator;
     
        //Methods
     
        public Bill(Money amount, Date dueDate, String originator){
            amount = (setAmount);                                               ************************setAmount
            duedate = (setDate);
            originator = (setOriginator);
     
        }
     
        public Bill(Bill toCopy){
     
        }
     
        public Money getAmount(){
            return amount;
        }
     
        public Date getDueDate(){
            return dueDate;
        }
     
        public String getOriginator(){
            return originator; 
        }
     
        public boolean isPaid(){
            if(!datePaid == null){               *****************datePaid
                return true;
            }
        }
     
        public void setPaid(Date onDay){
           if(dueDate > paidDate){
               System.out.println("The due date has passed");
           }else{
               paidDate = onDay;
           }
        }
     
        public void setUnpaid(){
            datePaid = null;
        }
     
        public void setDueDate(Date nextDate){
            dueDate = nextDate;
        }
     
        public void setAmount(Money amountGiven){
            if(amountGiven > 0){    //how else should i be protecting this?
                amount = amountGiven;
            }
        }
     
        public void setOriginator(String originatorGiven){
            originator = originatorGiven;
        }
     
        public String toString(){
            if(datePaid == null){
                return originator + "owes" + amount + "by the due date" + dueDate;
            }else{
                return originator + "paid" + amount + "by the due date" + dueDate
                       + "it was paid on" + datePaid;
            }
        }
     
        public boolean equals(Bill toCompare){
     
        }
     
     
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Cannot Find Symbol Compiling Error

    getting a Cannot find symbol error
    That means the compiler can not find the definition for a class, variable or method.

    Copy the full text of the error messages and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: Cannot Find Symbol Compiling Error

    #1: cannot find symbol - variable setAmount
    #2: cannot find symbol - variable datePaid

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,166
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Cannot Find Symbol Compiling Error

    #1: cannot find symbol - variable setAmount
    #2: cannot find symbol - variable datePaid
    All variables used in a program must be defined.
    Either add definitions for the variables that need to be defined,
    or change the code so it does not use undefined variables.
    For example: Check the spelling.
    Make sure the definition is in scope (within same {}s) with where the variable is being referenced.
    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following User Says Thank You to Norm For This Useful Post:

    Kristenw17 (April 22nd, 2013)

  6. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    26
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: Cannot Find Symbol Compiling Error

    Thank you very much. I was able to find my error.

Similar Threads

  1. Error:Cannot find Symbol
    By Leonardo1143 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 13th, 2013, 06:40 PM
  2. [SOLVED] Compiling Package, cannot find symbol
    By Actinistia in forum Java Theory & Questions
    Replies: 1
    Last Post: November 6th, 2012, 02:19 PM
  3. [SOLVED] cannot find symbol error
    By Topflyt in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 5th, 2011, 08:57 AM
  4. error :cannot find symbol
    By iswan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 1st, 2011, 08:26 AM
  5. cannot find symbol Error
    By bananasplitkids in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 9th, 2010, 02:36 AM

Tags for this Thread