Welcome to Dream.In.Code
Become a Java Expert!

Join 149,478 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,652 people online right now. Registration is fast and FREE... Join Now!




Constructors, Instance Variables, and Parameters

2 Pages V  1 2 >  
Reply to this topicStart new topic

Constructors, Instance Variables, and Parameters, Double and Char won't compile properly

xosunkist
20 Apr, 2007 - 01:33 PM
Post #1

D.I.C Head
**

Joined: 28 Mar, 2007
Posts: 69


My Contributions
Coding project file should have two classes.

The program class is named StudentStart and the object class is named Student.

The Student class should be used to create three student objects.

Each student object should be instantiated with five arguments using a constructor to initialize the instance variables.

The instance variables should contain the student's name, their student number and the scores they received on each of three tests worth 100 points if they received all the possible points.

The average grade for the three test scores should be calculated and a letter grade determined for the average grade in the constructor when the student object is instantiated.

The Student class should also contain the writeOutput method used to display on the monitor the student name, student number, test scores receive, average grade for the three test scores and the letter grade the student will receive.


(Here is what I have below for this project. It does not compile or recognize the double or char. What am I doing wrong?)
CODE



/* The Student class contains four constructors that

are used to initialize variables when Student objects

are created.  It also contains the output method

used by the program StudentStart.java to output information

about the object to the monitor Constructors are used

to initialize variables.  A constructor does not use

a return type in the heading. Also a constructor's name

is identical to the class name.  Constructors cannot be

invoked except when a new object is created. */



public class Student

{



            /* String, double, and char variables declared but not initialized.*/



            private String stName;

            private String stStudentid;

             private double Testone;

              private double Testtwo;

            private double Testthree;

            private char Letter;




            /*

               This constructor is called the default constructor

               because it has no parameters and receives no arguments.

               */



            public Student()



            {



            stName  = "Student Name: ";

            stStudentid = "Student #: ";

            Testone = "TESTING: ";

            Testtwo = "TESTING: ";

            Testthree = "TESTING: ";

            Letter = "TESTING: ";









            } /* end of Student default constructor -*/





            /* This constructor is used when new objects are created

               with one String argument. */
















            /* The first line of the method is called the method

               heading. The statements between the {  } curly braces

               are considered the body of the method. Together they

               are called the method definition. The writeOutput

               method return type void because it returns no values to

               the computer.  It is public so any program can access

               it. This method is used in this program to print the

               current values of the instance variables in each

               object when the respective object calls the writeOutput

               method.*/

public Student(String stName, String stStudentid, double Testone, double Testtwo, double Testthree)

{
                           stName = "Student Name: " + stName + "";

                           stStudentid = "Student #: " + stStudentid + "";

                           Testone = "Grades: " + Testone + Testtwo + Testthree + "";

                           Letter = "Letter Grade: " + Letter + "\n\n";
}




           public void writeOutput()



            {

            System.out.println(stName);

            System.out.println(stStudentid);

            System.out.println(Testone);

            System.out.println(Testtwo);

            System.out.println(Testthree);

            System.out.println(Letter);


            }    /* end of writeOutput method */









}     /*end of class Student*/





and StudentStart

CODE


/* This is a simple program to demonstrate

  how java can create three student objects from a

  class called Student using four constructors

  in the Student class.



  A Student constructor is called for each of the

  objects you create.  However a different

  constructor is called for each object since

  a different number of arguments is sent to

  the constructor each time. The constructor

  is used if the constructors parameters match

  the arguments sent in type and number.

  The three objects we create are named StudentA,

  StudentB and StudentC. We are using two class

  files in this project. They are Student

  in the StudentStart.java file and Student in the

  Student.java file. StudentStart is the program

  file because it contains the method named:

  public static void main(String[] args)

  */



public class StudentStart

{



            public static void main(String[] args)

            {





            /* Each of the following statements creates

            a Student object by making a copy of the class

            named Student.  It then assigns them different

            names. These objects are named StudentA, StudentB and

            StudentC. We refer to this as instantiating

            (making an instant copy of the class)

            We initialize variables in these objects using

            constructors. The arguments in the parentheses

            are used by the constructor to initialize the

            instance variables in the object in accordance with

            the method definition for the constructor.

            In this example the new objects are enclosed in

            quotation marks as literal strings because the

            constructors use type String parameters.*/





            Student studentA = new Student("Ugly Betty", "789", "100", "80", "90", "C");



            Student studentB = new Student("Mary Jane", "123", "80", "75", "65", "B");



            Student studentC = new Student("Luke Sky", "456", "70", "65", "86", "A");










    /* The following statements call the output

    method in each of the objects as indicated.

    The name to the left of the period is the

    object name and the name to the right of the

    period is the output method. Remember you

    cannot call any of the constructor methods

    after the object has been created.  The

    output method illustrates displays information

    showing a different constructor was used

    to initialize the variables in each object.*/





            studentA.writeOutput();



            studentB.writeOutput();



            studentC.writeOutput();








            }        /*end of main method*/



}           /*end of class StudentStart*/



User is offlineProfile CardPM
+Quote Post

beef
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 02:01 PM
Post #2

D.I.C Head
Group Icon

Joined: 2 Nov, 2006
Posts: 128


My Contributions
For one, you are trying to put strings in your double variables. That won't work.

CODE

//Bad
Testone = "TESTING";

//Better (the little d tells java this is a double instead of an int)
Testone = 0d;


Another problem I see is in your constructor where you pass in values, you aren't specifying which Testone you are putting stuff in, and java will put it in the one that is most local. You should either use different names for your input variables or add a this. in front of your first set of values like this:

CODE
this.Testone = Testone;


This post has been edited by beef: 20 Apr, 2007 - 02:02 PM
User is offlineProfile CardPM
+Quote Post

xosunkist
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 02:39 PM
Post #3

D.I.C Head
**

Joined: 28 Mar, 2007
Posts: 69


My Contributions
I guess I don't understand. What about the char?

QUOTE(beef @ 20 Apr, 2007 - 03:01 PM) *

For one, you are trying to put strings in your double variables. That won't work.

CODE

//Bad
Testone = "TESTING";

//Better (the little d tells java this is a double instead of an int)
Testone = 0d;


Another problem I see is in your constructor where you pass in values, you aren't specifying which Testone you are putting stuff in, and java will put it in the one that is most local. You should either use different names for your input variables or add a this. in front of your first set of values like this:

CODE
this.Testone = Testone;



User is offlineProfile CardPM
+Quote Post

xosunkist
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 02:48 PM
Post #4

D.I.C Head
**

Joined: 28 Mar, 2007
Posts: 69


My Contributions
Okay, now I need the other two grades to show up and they aren't. I'm supposed to have three grades and then average them with a letter grade.

Revised Student.java

CODE



/* The Student class contains four constructors that

are used to initialize variables when Student objects

are created.  It also contains the output method

used by the program StudentStart.java to output information

about the object to the monitor Constructors are used

to initialize variables.  A constructor does not use

a return type in the heading. Also a constructor's name

is identical to the class name.  Constructors cannot be

invoked except when a new object is created. */



public class Student

{



            /* String, double, and char variables declared but not initialized.*/



            private String stName;

            private String stStudentid;

             private double Grades;

             private char Letter;




            /*

               This constructor is called the default constructor

               because it has no parameters and receives no arguments.

               */



            public Student()



            {



            stName  = "Student Name: ";

            stStudentid = "Student #: ";

             Grades = 0d;

              Letter = Letter;









            } /* end of Student default constructor -*/





            /* This constructor is used when new objects are created

               with one String argument. */
















            /* The first line of the method is called the method

               heading. The statements between the {  } curly braces

               are considered the body of the method. Together they

               are called the method definition. The writeOutput

               method return type void because it returns no values to

               the computer.  It is public so any program can access

               it. This method is used in this program to print the

               current values of the instance variables in each

               object when the respective object calls the writeOutput

               method.*/

public Student(String stName, String stStudentid, double Grades)

{
                           stName = "Student Name: " + stName + "";

                           stStudentid = "Student #: " + stStudentid + "";

                           Grades = "Grades: " + Grades + "";

                           Letter = "Letter Grade: " + Letter + "";
}




           public void writeOutput()



            {

            System.out.println(stName);

            System.out.println(stStudentid);

            System.out.println(Grades);

            System.out.println(Letter);


            }    /* end of writeOutput method */









}     /*end of class Student*/




Revised
StudentStart.java


CODE


/* This is a simple program to demonstrate

  how java can create three student objects from a

  class called Student using four constructors

  in the Student class.



  A Student constructor is called for each of the

  objects you create.  However a different

  constructor is called for each object since

  a different number of arguments is sent to

  the constructor each time. The constructor

  is used if the constructors parameters match

  the arguments sent in type and number.

  The three objects we create are named StudentA,

  StudentB and StudentC. We are using two class

  files in this project. They are Student

  in the StudentStart.java file and Student in the

  Student.java file. StudentStart is the program

  file because it contains the method named:

  public static void main(String[] args)

  */



public class StudentStart

{



            public static void main(String[] args)

            {





            /* Each of the following statements creates

            a Student object by making a copy of the class

            named Student.  It then assigns them different

            names. These objects are named StudentA, StudentB and

            StudentC. We refer to this as instantiating

            (making an instant copy of the class)

            We initialize variables in these objects using

            constructors. The arguments in the parentheses

            are used by the constructor to initialize the

            instance variables in the object in accordance with

            the method definition for the constructor.

            In this example the new objects are enclosed in

            quotation marks as literal strings because the

            constructors use type String parameters.*/





            Student studentA = new Student("Ugly Betty", "789", "100", "80", "90", "C");



            Student studentB = new Student("Mary Jane", "123", "80", "75", "65", "B");



            Student studentC = new Student("Luke Sky", "456", "70", "65", "86", "A");










    /* The following statements call the output

    method in each of the objects as indicated.

    The name to the left of the period is the

    object name and the name to the right of the

    period is the output method. Remember you

    cannot call any of the constructor methods

    after the object has been created.  The

    output method illustrates displays information

    showing a different constructor was used

    to initialize the variables in each object.*/





            studentA.writeOutput();



            studentB.writeOutput();



            studentC.writeOutput();








            }        /*end of main method*/



}           /*end of class StudentStart*/


User is offlineProfile CardPM
+Quote Post

beef
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 03:17 PM
Post #5

D.I.C Head
Group Icon

Joined: 2 Nov, 2006
Posts: 128


My Contributions
For the char it's kind of the same, a char can only hold one letter and it's not exactly the same as a string. If you want to give it a value use single quotes instead of double ex.
CODE
char Letter = 'a';


The way you have it now, Student is only accepting name, id and grades(as one value)

If you need to display all three, you'll have to keep track of all three in Student. An easy way to do this would be an array if you've covered that yet. If not, use 3 values like you had before.
User is offlineProfile CardPM
+Quote Post

xosunkist
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 03:19 PM
Post #6

D.I.C Head
**

Joined: 28 Mar, 2007
Posts: 69


My Contributions
Here is a code I worked on previously that compiled with no errors. When I submitted it to my teacher this is what he said:

You will need to use String
and numbers. So, you have:

private String stNumber;

private String stMake;

private String stTestone;

private String stTesttwo;

private String stTestthree;

private String stLetter;


First, of all make doesn't make sense here. That was for a Car, a car
has a make, model. Well, you're dealing with a Student here so these
should be something like: name, studentId
finally, like I said we don't want to use all String types. The Test
scores should be of type int or type double. The stLetter should be of
type char as it is a single character.

So, when you create a student you don't need all those constructors you
copied from the Car example, you really only need 1. That constructor
will take 5 parameters. The first 2 will be String (for name and id)
and the last 3 will be numbers for each of the test scores.
then, inside the body of the constructor you can compute the average
(you still need to create an instance variable for that) After you
compoute the average, you can use an if statment (still inside the
constructor) to determin what letter grad the student will receive.



STUDENT.JAVA :

CODE



/* The Student class contains four constructors that

are used to initialize variables when Student objects

are created.  It also contains the output method

used by the program StudentStart.java to output information

about the object to the monitor Constructors are used

to initialize variables.  A constructor does not use

a return type in the heading. Also a constructor's name

is identical to the class name.  Constructors cannot be

invoked except when a new object is created. */



public class Student

{



            /* String variables declared but not initialized.*/



            private String stNumber;

            private String stMake;

            private String stTestone;

            private String stTesttwo;

            private String stTestthree;

            private String stLetter;




            /*

               This constructor is called the default constructor

               because it has no parameters and receives no arguments.

               */



            public Student()



            {



            stNumber  = "Student Name: ";

            stMake = "Student #: ";

            stTestone = "Grade 1: ";

            stTesttwo = "Grade 2: ";

            stTestthree = "Grade 3: \n\n";





            } /* end of Student default constructor -*/





            /* This constructor is used when new objects are created

               with one String argument. */



            public Student(String objectNum)



            {



            stNumber = "Student Name: " + objectNum + "";

            stMake = "Student #: ";

            stTestone = "Grade 1: ";

            stTesttwo = "Grade 2: ";

            stTestthree = "Grade 3: \n\n";



            }  /* end of Student constructor -- one parameter */





            /*  This constructor is used when new objects are created

                        with two String arguments.  */



            public Student(String objectNum, String make)



            {



            stNumber = "Student Name: " + objectNum + "";

            stMake = "Student #: " + make + "";

            stTestone = "Grade 1: ";

            stTesttwo = "Grade 2: ";

            stTestthree = "Grade 3: \n\n";





            }  /* end of Student constructor -- two parameters */



            /* This constructor is used when new objects are created

               with three String arguments. */



            public Student(String objectNum, String make, String
Testone)



            {



            stNumber = "Student Name: " + objectNum + "";

            stMake = "Student #: " + make + "";

            stTestone = "Grade 1: " + Testone + " \n\n";

            stTesttwo = "Grade 2: ";

            stTestthree = "Grade 3: \n\n";





            }    /* end of Student constructor -- three parameters */

            public Student(String objectNum, String make, String Testone, String
Testtwo)

            {

                stNumber = "Student Name: " + objectNum + "";

                stMake = "Student #: " + make + "";

                stTestone = "Grade 1: " + Testone + "";

                stTesttwo = "Grade 2: " + Testtwo + "";

                stTestthree = "Grade 3: ";

                stLetter = "Letter Grade: \n\n";

        }

            /* The first line of the method is called the method

               heading. The statements between the {  } curly braces

               are considered the body of the method. Together they

               are called the method definition. The writeOutput

               method return type void because it returns no values to

               the computer.  It is public so any program can access

               it. This method is used in this program to print the

               current values of the instance variables in each

               object when the respective object calls the writeOutput

               method.*/

public Student(String objectNum, String make, String Testone, String
Testtwo, String Testthree)

{
                           stNumber = "Student Name: " + objectNum + "";

                           stMake = "Student #: " + make + "";

                           stTestone = "Grade 1: " + Testone + "";

                           stTesttwo = "Grade 2: " + Testtwo + "";

                           stTestthree = "Grade 3: " + Testthree + "";

                           stLetter = "Letter Grade: \n\n";
}


public Student(String objectNum, String make, String Testone, String Testtwo, String Testthree, String letter)

{
                            stNumber = "Student Name: " + objectNum + "";

                               stMake = "Student #: " + make + "";

                               stTestone = "Grade 1: " + Testone + "";

                               stTesttwo = "Grade 2: " + Testtwo + "";

                               stTestthree = "Grade 3: " + Testthree + "";

                               stLetter = "Letter Grade: " + letter + "\n\n";
                        }

           public void writeOutput()



            {

            System.out.println(stNumber);

            System.out.println(stMake);

            System.out.println(stTestone);

            System.out.println(stTesttwo);

            System.out.println(stTestthree);

            System.out.println(stLetter);


            }    /* end of writeOutput method */









}     /*end of class Student*/





STUDENTSTART.JAVA :

CODE



/* This is a simple program to demonstrate

  how java can create three student objects from a

  class called Student using four constructors

  in the Student class.



  A Student constructor is called for each of the

  objects you create.  However a different

  constructor is called for each object since

  a different number of arguments is sent to

  the constructor each time. The constructor

  is used if the constructors parameters match

  the arguments sent in type and number.

  The three objects we create are named StudentA,

  StudentB and StudentC. We are using two class

  files in this project. They are Student

  in the StudentStart.java file and Student in the

  Student.java file. StudentStart is the program

  file because it contains the method named:

  public static void main(String[] args)

  */



public class StudentStart

{



            public static void main(String[] args)

            {





            /* Each of the following statements creates

            a Student object by making a copy of the class

            named Student.  It then assigns them different

            names. These objects are named StudentA, StudentB and

            StudentC. We refer to this as instantiating

            (making an instant copy of the class)

            We initialize variables in these objects using

            constructors. The arguments in the parentheses

            are used by the constructor to initialize the

            instance variables in the object in accordance with

            the method definition for the constructor.

            In this example the new objects are enclosed in

            quotation marks as literal strings because the

            constructors use type String parameters.*/





            Student studentA = new Student("Ugly Betty", "789", "100", "80", "90", "C");



            Student studentB = new Student("Mary Jane", "123", "80", "75", "65", "B");



            Student studentC = new Student("Luke Sky", "456", "70", "65", "86", "A");










    /* The following statements call the output

    method in each of the objects as indicated.

    The name to the left of the period is the

    object name and the name to the right of the

    period is the output method. Remember you

    cannot call any of the constructor methods

    after the object has been created.  The

    output method illustrates displays information

    showing a different constructor was used

    to initialize the variables in each object.*/





            studentA.writeOutput();



            studentB.writeOutput();



            studentC.writeOutput();








            }        /*end of main method*/



}           /*end of class StudentStart*/



User is offlineProfile CardPM
+Quote Post

beef
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 03:52 PM
Post #7

D.I.C Head
Group Icon

Joined: 2 Nov, 2006
Posts: 128


My Contributions
You're right, it would be better to use doubles for the score and a char for letter, but if you're teacher wants you to do it this way, do it so you get the grade and learn the right way on the side if you have to.

This post has been edited by beef: 20 Apr, 2007 - 03:52 PM
User is offlineProfile CardPM
+Quote Post

xosunkist
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 03:53 PM
Post #8

D.I.C Head
**

Joined: 28 Mar, 2007
Posts: 69


My Contributions
Hello, I just have some questions to my project. I have attached a new revised version. A lot of compiler issues. Still haven't gotten to do the averages yet, still stuck on this part. Here is what I have been working on below:
-------------------------------------------------------------->


I have changed Testone, Testtwo, and Testthree to type double.

I have changed letter to type char.

See below:

public Student(String Name, String Id, double Testone, double Testtwo, double Testthree, char letter)
-------------------------------------------------------------------------------------------------------------------
I also changed this as well from String to double and char:


private String stName; <----- Stays a String
private String stId; <----- Stays a String
private double stTestone; <------ changed to double
private double stTesttwo; <----- changed to double
private double stTestthree; <------ changed to double
private char stLetter; <-------- changed to char
----------------------------------------------------------------------------------------------------------------
I think apart of my problem lies in here somewhere, but I changed the last item.

stName = "Student Name: ";
stId = "Student #: ";
stTestone = "Grade 1: ";
stTesttwo = "Grade 2: ";
stTestthree = "Grade 3: \n\n";
char stletter = 'a'; <--------------------changed
---------------------------------------------------------------------------------------------------------------------
I corrected my constructor so it includes five parameters as shown below:


public Student(String Name, String Id, double Testone, double Testtwo, double Testthree)
{
stName = "Student Name: " + Name+ "";
stId= "Student #: " + Id + "";
stTestone = "Grade 1: " + Testone + "";
stTesttwo = "Grade 2: " + Testtwo + "";
stTestthree = "Grade 3: " + Testthree + "";
stLetter = "Letter Grade: " + letter + "\n\n";
}
public void writeOutput()

{
System.out.println(stName);
System.out.println(stId);
System.out.println(stTestone);
System.out.println(stTesttwo);
System.out.println(stTestthree);
System.out.println(stLetter);

}


------------------------------------------------------------------------------------------------------------------------
On the StudentStart.java I get this error message below:

-------------->
C:\cs151\StudentStart.java:16: cannot find symbol
symbol : constructor Student(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class Student
Student studentA = new Student("Ugly Betty", "789", "100", "80", "90", "C");
^
C:\cs151\StudentStart.java:20: cannot find symbol
symbol : constructor Student(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class Student
Student studentB = new Student("Mary Jane", "123", "80", "75", "65", "B");
^
C:\cs151\StudentStart.java:24: cannot find symbol
symbol : constructor Student(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class Student
Student studentC = new Student("Luke Sky", "456", "70", "65", "86", "A");
^
.\Student.java:35: incompatible types
found : java.lang.String
required: double
stTestone = "Grade 1: ";
^
.\Student.java:37: incompatible types
found : java.lang.String
required: double
stTesttwo = "Grade 2: ";
^
.\Student.java:39: incompatible types
found : java.lang.String
required: double
stTestthree = "Grade 3: \n\n";
^
.\Student.java:56: incompatible types
found : java.lang.String
required: double
stTestone = "Grade 1: " + Testone + "";
^
.\Student.java:58: incompatible types
found : java.lang.String
required: double
stTesttwo = "Grade 2: " + Testtwo + "";
^
.\Student.java:60: incompatible types
found : java.lang.String
required: double
stTestthree = "Grade 3: " + Testthree + "";
^
.\Student.java:62: incompatible types
found : java.lang.String
required: char
stLetter = "Letter Grade: " + letter + "\n\n";
^
10 errors
Tool completed with exit code 1
---------------------------------------------------------------------------------------------------------------------------------

On the Student.java, I get this error message:

---------------->
C:\cs151\Student.java:35: incompatible types
found : java.lang.String
required: double
stTestone = "Grade 1: ";
^
C:\cs151\Student.java:37: incompatible types
found : java.lang.String
required: double
stTesttwo = "Grade 2: ";
^
C:\cs151\Student.java:39: incompatible types
found : java.lang.String
required: double
stTestthree = "Grade 3: \n\n";
^
C:\cs151\Student.java:56: incompatible types
found : java.lang.String
required: double
stTestone = "Grade 1: " + Testone + "";
^
C:\cs151\Student.java:58: incompatible types
found : java.lang.String
required: double
stTesttwo = "Grade 2: " + Testtwo + "";
^
C:\cs151\Student.java:60: incompatible types
found : java.lang.String
required: double
stTestthree = "Grade 3: " + Testthree + "";
^
C:\cs151\Student.java:62: incompatible types
found : java.lang.String
required: char
stLetter = "Letter Grade: " + letter + "\n\n";
^
7 errors
Tool completed with exit code 1

--------------------------------------------------
NEW CODE !! NEW CODE !!! BELOW:
STUDENT.JAVA
-------------------------------------------------


CODE





public class Student

{

            private String stName;

            private String stId;

            private double stTestone;

            private double stTesttwo;

            private double stTestthree;

            private char stLetter;



        public Student()



            {



            stName  = "Student Name: ";

            stId = "Student #: ";

            stTestone = "Grade 1: ";

            stTesttwo = "Grade 2: ";

            stTestthree = "Grade 3: \n\n";

            char stletter = 'a';



            }



public Student(String Name, String Id, double Testone, double Testtwo, double Testthree, char letter)

{
                            stName = "Student Name: " + Name + "";

                               stId = "Student #: " + Id + "";

                               stTestone = "Grade 1: " + Testone + "";

                               stTesttwo = "Grade 2: " + Testtwo + "";

                               stTestthree = "Grade 3: " + Testthree + "";

                               stLetter = "Letter Grade: " + letter + "\n\n";
                        }

           public void writeOutput()



            {

            System.out.println(stName);

            System.out.println(stId);

            System.out.println(stTestone);

            System.out.println(stTesttwo);

            System.out.println(stTestthree);

            System.out.println(stLetter);


            }



}



---------------------------------------------
NEW CODE!! NEW CODE!! BELOW:
STUDENTSTART.JAVA
----------------------------
CODE






public class StudentStart

{



            public static void main(String[] args)

            {


            Student studentA = new Student("Ugly Betty", "789", "100", "80", "90", "C");



            Student studentB = new Student("Mary Jane", "123", "80", "75", "65", "B");



            Student studentC = new Student("Luke Sky", "456", "70", "65", "86", "A");





            studentA.writeOutput();



            studentB.writeOutput();



            studentC.writeOutput();
        }
    }






User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Constructors, Instance Variables, And Parameters
20 Apr, 2007 - 03:58 PM
Post #9

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,348



Thanked: 51 times
Dream Kudos: 25
My Contributions
The first errors are coming because you are passing all you parameters to the constructor as strings, when in reality only the first two and last should be. Remove the quotes from the numbers in the call to the constructors, and perhaps use single quotes for the final parameter. The other errors occur because the parameters are incorrect.
User is offlineProfile CardPM
+