473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

cannot find symbol constructor

New to Java. Working on this and ran into this problem. Any clues?
java:42: cannot find symbol
symbol : constructor Pay()
location: class Pay
Pay Emp1 = new Pay();
^
43: cannot find symbol
symbol : constructor Pay()
location: class Pay
Pay Emp2 = new Pay();

This is the coding.. Ya it is a working process.
Expand|Select|Wrap|Line Numbers
  1. public class Pay
  2. {
  3.     private double hoursWorked;
  4.     private double payRate; 
  5.     private double grossPay;
  6.  
  7. public Pay(double hoursWorked, double payRate)
  8.     {
  9.         hoursWorked = 0;
  10.         payRate = 9.75;
  11.     }
  12.  
  13.   public double gethoursWorked()
  14.     {
  15.     return hoursWorked;
  16.     }
  17.  // @param h Store the hours value.
  18.  public void sethoursWorked(double h)
  19.      {
  20.     hoursWorked = h;
  21.     }
  22.  
  23. public double getpayRate()
  24.     {
  25.     return payRate;
  26.     }
  27.  
  28.  public void setpayRate(double p)
  29.      {
  30.     payRate = p;
  31.     }
  32.  
  33. public double getgrossPay()
  34.     {
  35.     return payRate * hoursWorked;
  36.     }    
  37. }     
  38. class testPay
  39. {
  40.     public static void main(String[] args)
  41.      {
  42.           Pay Emp1 = new Pay();
  43.           Pay Emp2 = new Pay();
  44.         Emp1.sethoursWorked(48);
  45.         Emp2.setpayRate(15.60);
  46.  
  47.     System.out.println( + Emp1.gethoursWorked());    
  48. }
  49. }    
  50.  
Sep 25 '07 #1
2 2956
JosAH
11,448 Expert 8TB
Well, I don't see a ctor that doesn't take parameters either, just like the compiler.
I do see a ctor that takes two doubles as its parameters but you're not using that,
you're trying to invoke Pay(), but there isn't such a ctor.

kind regards,

Jos
Sep 25 '07 #2
dmjpro
2,476 2GB
New to Java. Working on this and ran into this problem. Any clues?
java:42: cannot find symbol
symbol : constructor Pay()
location: class Pay
Pay Emp1 = new Pay();
^
43: cannot find symbol
symbol : constructor Pay()
location: class Pay
Pay Emp2 = new Pay();

This is the coding.. Ya it is a working process.
Expand|Select|Wrap|Line Numbers
  1. public class Pay
  2. {
  3.     private double hoursWorked;
  4.     private double payRate; 
  5.     private double grossPay;
  6.  
  7. public Pay(double hoursWorked, double payRate)
  8.     {
  9.         hoursWorked = 0;
  10.         payRate = 9.75;
  11.     }
  12.  
  13.   public double gethoursWorked()
  14.     {
  15.     return hoursWorked;
  16.     }
  17.  // @param h Store the hours value.
  18.  public void sethoursWorked(double h)
  19.      {
  20.     hoursWorked = h;
  21.     }
  22.  
  23. public double getpayRate()
  24.     {
  25.     return payRate;
  26.     }
  27.  
  28.  public void setpayRate(double p)
  29.      {
  30.     payRate = p;
  31.     }
  32.  
  33. public double getgrossPay()
  34.     {
  35.     return payRate * hoursWorked;
  36.     }    
  37. }     
  38. class testPay
  39. {
  40.     public static void main(String[] args)
  41.      {
  42.           Pay Emp1 = new Pay();
  43.           Pay Emp2 = new Pay();
  44.         Emp1.sethoursWorked(48);
  45.         Emp2.setpayRate(15.60);
  46.  
  47.     System.out.println( + Emp1.gethoursWorked());    
  48. }
  49. }    
  50.  
Look if you provide any Constructor then your compiler will provide a default Constructor with no arguments but whenever you provide at least one Constructor then your default Constructor should be your own.

Here you have to provide your own default Constructor, means Constructor with no arguments.

Kind regards,
Dmjpro.
Sep 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
1
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import...
1
by: Shiva48 | last post by:
Thanks to Gannon11 and ro351988- Moderator. I give below the complete Java file and pls help me to rectify the errors. package com.wrox.proj2ee.ch10.app; import java.io.*; import...
1
by: Naha | last post by:
Hi Guys, Can come one help me with this code, i am getting an error on line 14:Cannot find symbol constructor Details java.lang.string.java.lang.string. import javax.servlet.*; import...
4
by: jingchua | last post by:
Hi, can anyone help out here???? I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
15
by: Seral1969 | last post by:
Hi, I'm new to Java... I've been trying to get one of my professor's examples to work... He says that the code is fine, but I keep getting 4 "cannot resolve symbol" errors when I try to compile...
10
by: CodeNoob | last post by:
please help been working on a project got it down to 5 errors from 100 now i have no idea what to do. Errors: init: deps-jar: Created dir: C:\Users\Tommy\Desktop\build\classes Compiling 306...
2
suzee_q00
by: suzee_q00 | last post by:
Compiler seems to be hanging up on "new" but I know it isn't but I can't seem to figure out what it is that it doesn't like. Been chasing my tail for the last couple of days. Any help would be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.