473,671 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot resolve symbol?

10 New Member
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 the ShowStudent.jav a file...

The code for the Student class and ShowStudent program are listed below...

PLEASE HELP!!!


Expand|Select|Wrap|Line Numbers
  1. // Student.java
  2. // creates a class to store info about a student
  3.  
  4. class Student
  5. {
  6.     // the private data members
  7.     private int IDnumber;
  8.     private int hours;
  9.     private int points;
  10.  
  11.     // constructor added in last part of project
  12.     Student()
  13.     {
  14.         IDnumber = 77375;
  15.         points = 12;
  16.         hours = 3;
  17.     }
  18.     // end of constructor
  19.  
  20.     // the public get and set methods
  21.     public void setIDnumber(int number)
  22.     {
  23.         IDnumber = number;
  24.     }
  25.  
  26.  
  27.     public int getPoints()
  28.     {
  29.         return points;
  30.     }
  31.  
  32.     // methods to display the fields
  33.     public void showIDnumber()
  34.     {
  35.         System.out.println("ID Number is: " + IDnumber);
  36.     }
  37.  
  38.     public void showHours()
  39.     {
  40.         System.out.println("Credit Hours: " + hours);
  41.     }
  42.  
  43.     public void showPoints()
  44.     {
  45.         System.out.println("Points Earned: " + points);
  46.     }
  47.  
  48.     public double getGradePoint()
  49.     {
  50.         return (double)points / hours;
  51.     }
  52.  
  53. }
  54.  
  55.  
  56.  
  57. // ShowStudent.java
  58. // client to test the Student class
  59.  
  60. class ShowStudent
  61. {
  62.     public static void main (String args[])
  63.     {
  64.         student pupil = new student();
  65.  
  66.  
  67.         pupil.showIDnumber();
  68.         pupil.showPoints();
  69.         pupil.showHours();
  70.         System.out.println("The grade point average of the studnet created by constructor is "
  71.             + pupil.getGradePoint()+"\n\n");
  72.  
  73.         Student s2 = new Student();
  74.         s2.setIDnumber(12345);
  75.         s2.setPoints(66);
  76.         s2.setHours(20);
  77.         s2.showIDnumber();
  78.         s2.showPoints();
  79.         s2.showHours();
  80.         System.out.println("The grade point average of another student is "
  81.             + s2.getGradePoint()+"\n");
  82.  
  83.     }
  84. }
Feb 16 '08 #1
15 6431
Ganon11
3,652 Recognized Expert Specialist
In ShowStudent, you say:

Expand|Select|Wrap|Line Numbers
  1. student pupil = new student();
but the Student class is spelled with a capital S, like you used for s2:

Expand|Select|Wrap|Line Numbers
  1. Student s2 = new Student();
The compiler is looking for a separate class named student, which doesn't exist.
Feb 16 '08 #2
Seral1969
10 New Member
I changed the the S to uppercase, but I still get the same errors...
Feb 16 '08 #3
Ganon11
3,652 Recognized Expert Specialist
Can you copy/paste the exact errors? Put them between [code] tags so they are easier to read, please.
Feb 16 '08 #4
Seral1969
10 New Member
Here is the uptated ShowStudent.jav a file...

There are no changes to the Student.java file...

I have a screenshot of the error, but don't know how to attach it...


Expand|Select|Wrap|Line Numbers
  1. // ShowStudent.java
  2. // client to test the Student class
  3.  
  4. public class ShowStudent
  5. {
  6.     public static void main (String args[])
  7.     {
  8.         Student pupil = new Student();
  9.  
  10.  
  11.         pupil.showIDnumber();
  12.         pupil.showPoints();
  13.         pupil.showHours();
  14.         System.out.println("The grade point average of the studnet created by constructor is "
  15.             + pupil.getGradePoint()+"\n\n");
  16.  
  17.         Student s2 = new Student();
  18.         s2.setIDnumber(12345);
  19.         s2.setPoints(66);
  20.         s2.setHours(20);
  21.         s2.showIDnumber();
  22.         s2.showPoints();
  23.         s2.showHours();
  24.         System.out.println("The grade point average of another student is "
  25.             + s2.getGradePoint()+"\n");
  26.  
  27.     }
  28. }
Feb 16 '08 #5
Seral1969
10 New Member
I have set comments to the problem areas...

Expand|Select|Wrap|Line Numbers
  1. // ShowStudent.java
  2. // client to test the Student class
  3.  
  4. public class ShowStudent
  5. {
  6.     public static void main (String args[])
  7.     {
  8.         Student pupil = new Student();// 2 cannot resolve sybmol... points to 'S' in Student 
  9.  
  10.  
  11.         pupil.showIDnumber();
  12.         pupil.showPoints();
  13.         pupil.showHours();
  14.         System.out.println("The grade point average of the studnet created by constructor is "
  15.             + pupil.getGradePoint()+"\n\n");
  16.  
  17.         Student s2 = new Student();// 2 cannot resolve sybmol points to 'S in Student
  18.         s2.setIDnumber(12345);
  19.         s2.setPoints(66);
  20.         s2.setHours(20);
  21.         s2.showIDnumber();
  22.         s2.showPoints();
  23.         s2.showHours();
  24.         System.out.println("The grade point average of another student is "
  25.             + s2.getGradePoint()+"\n");
  26.  
  27.     }
  28. }
Feb 16 '08 #6
Ganon11
3,652 Recognized Expert Specialist
Now we're getting somewhere.

It looks like ShowStudent can't find the Student class - are they in the same folder?

If you can't get it to work, try copying/pasting the main into the Student class - that way, you're only working with one file, and there shouldn't be any unresolved errors.
Feb 16 '08 #7
Seral1969
10 New Member
Yes...

Both are in C:\Error...
Feb 16 '08 #8
Seral1969
10 New Member
The exercise says that I have to use two files...

I've even set the Student class to public...

No dice...
Feb 16 '08 #9
Ganon11
3,652 Recognized Expert Specialist
Try compiling Student.java first? Other than that, I don't know how to help you.
Feb 16 '08 #10

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

Similar topics

1
27776
by: Java script Dude | last post by:
I am investigating a solution to build all pages sent from my application servlet in UTF-8 encoding. From what I understand, I should be using HttpServletResponse.setCharacterEncoding("UTF-8"). The J2EE API clearly shows that this method is available with superclass ServletResponse but I am getting compile errors using NetBeans 3.6 final. Thanks for your help! Tim
1
24798
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both classes in the directory called temp and I do cd temp to this directory. Then I do javac HelloWorld.java Now I get the compile error HelloWorld.java:8 cannot resolve symbol
1
4622
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 com.sun.j3d.utils.geometry.*; import javax.media.j3d.*; import javax.vecmath.*;
3
2352
by: toish | last post by:
I have a program, aaa.java which creates an instance of another class(bbb.java). both java files are in a package entitled 'diss' bbb.java compiles sucessfully aaa.java throws a cannot resolve symbol error when aaa is referenced. aaa.java imports the package diss, as well as being part of it. both files are in the same directory. These files compile sucessfully using Java 1.5, when using Tomcat V.4 the above compilation error is thrown...
3
2365
by: adamrace | last post by:
Hi, i am fairly new to java and have been stuck on this for ages, basically i need to create a new object which gets a list of data from a text file, so i have this import java.io.*; import java.util.*; public class Tester {
3
3190
by: Sindhu Rani | last post by:
i hav created 3 classes in 3 different files. am gettin an error durin compilation. wat shud i do??? C:\s\source>javac -d ..\classes devtestdrive.java devtestdrive.java:5: cannot resolve symbol symbol : class device location: class devtestdrive device d1=new tv(); ^ devtestdrive.java:5: cannot resolve symbol symbol : class tv
0
1814
EntryTeam
by: EntryTeam | last post by:
At the screenshots you can see what libraries I've added to project, and still - those two essential classes are missing! What's wrong? Need your help.
1
2147
by: Charles Sherman | last post by:
public class area { public static void main(Strings args) { int height; int width; int area; int i; int e; for (i=1; i>=11; i++);
0
8403
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.