2 Replies - 417 Views - Last Post: 21 June 2012 - 06:21 PM Rate Topic: -----

#1 VikaTama  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 03-April 12

error: cannot find symbol

Posted 21 June 2012 - 06:08 PM

I had this working once in Netbeans, but now it keeps giving me 2 errors in this section of code.

  System.out.print("Enter Sales Person's First Name : ");
        Name = input.next();
        SalesPerson sale = new SalesPerson(Name);
        System.out.print("Enter the Annual Sale Amount for "+sale.getName()+" : ");
        amt = input.nextDouble();
        sale.setAnnualSale(amt);


The error is:

error:cannot find symbol
SalesPerson sale = new SalesPerson(Name);
^

I get two errors both identical just the ^ changes place from one capital S to the next capital S and still get the same thing, if I seperate SalesPerson into two words i get errors.Ive lower cased the S's in both SalesPerson and still get the same error. Can any one advice me on how to fix this problem, correctly.


Here is the full code incase you want to check it for yourself.

import java.util.Scanner; 

public class SalesPerson                          
{
    public static void main(String[] args)
    {
                Scanner input = new Scanner(System.in);
        double amt;
        String Name;         
                System.out.print("Enter Sales Person's First Name : ");
        Name = input.next();
        SalesPerson sale = new SalesPerson(Name);
        System.out.print("Enter the Annual Sale Amount for "+sale.getName()+" : ");
        amt = input.nextDouble();
        sale.setAnnualSale(amt);
        
              System.out.println("Total Annual Commission of "+sale.getName()+" is : $"+sale.getCompensation());
        sale.displayTable();
        
    }
}




Is This A Good Question/Topic? 0
  • +

Replies To: error: cannot find symbol

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: error: cannot find symbol

Posted 21 June 2012 - 06:19 PM

Your source code has been on a diet since you ran it last. It now requires:

A SalesPerson constructor that takes a String as an argument, and
The following methods: getName(), setAnnualSale(), getCompensation(), and displayTable().
Was This Post Helpful? 1
  • +
  • -

#3 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: error: cannot find symbol

Posted 21 June 2012 - 06:21 PM

You don't have a constructor of your SalesPerson class that takes in a string argument. What's with that?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1