PDA

View Full Version : help please


katCT
12-04-2005, 06:22 PM
I wrote a program and it wont run correctly anyone know why?

class student {
private string first name, last name
private address home address, school address
private int test1, test2, test3
}
class Address {
private string streetAddress, city, state
private long zip code
public student (String first, string last, Address home, Address school,intt1,intt2, intt3){
last name=last;
fist name=first;
home address=home;
school address=school;
test1=t1;
test2=t2;
test3=t3;
}
public student (String first, string last, Address home, Address school){
last name=last;
fist name=first;
home address=home;
school address=school;
test1=0;
test2=0;
test3=0;
}
public void set Test Score (int test number, int test score)
if (number == 1) {
test 1 == test score
else (
if (test number == 2)
test 2 == test score,
else
test 3 == test score,

public intgetTestScore(int testNumber)(
if (test number == 1)
return test1
else (
if (test number == 2)
return test 2
else
return test3.)
}
public double.Average (){
returns (test1 + test2 + test3)/3.
public string to string ()
{string result
result = first name +"n"+ last name +"n"+;
result = "HomeAddressln"+ homeAddress +"n";
result = "schoolAddressln"+ schoolAdress +"n";
result = "test1" + "test 1 + "n";
result = "test2" + "test 2 + "n";
result = "test3" + "test 3 + "n";
result = "average" +this.average()+"n";
}
}
class course {
static int numberstudent = 0;
String title;
student student1;
student student2;
student student3;
student student4;
student student5;
}
public course(string course_title)(
title=course_title,
)
public void addStudent (Student newStudent)(
numStudent ++,
Switch(num Students)(
case1 student 1 = new student;
break,
case2 student 2 = new student;
break,
case3 student 3 = new student;
break,
case4 student 4 = new student;
break,
case5 student 5 = new student;
break,
default: System out.println("No More students allowed in the class");
}
}
publib string to string ()
string resultsC
results += Student 1 to sting () +"n";
results += Student 2 to sting () +"n";
results += Student 3 to sting () +"n";
results += Student 4 to sting () +"n";
results += Student 5 to sting () +"n";
return result;
}

oracleguy
12-04-2005, 09:06 PM
Perhaps you could clarify what language this is exactly and what errors specifically you are having. Is it not compiling or just not executing correctly?

gsoft
12-04-2005, 09:28 PM
Some errors which stand out without knowing the language.


private string first name, last name
private address home address, school address



public void set Test Score (int test number, int test score)
if (number == 1) {
test 1 == test score
else (
if (test number == 2)
test 2 == test score,
else
test 3 == test score,


There are more scattered in the code, you cannot have a space inbetween variable names, I am yet to see any language that allows this, you must either join them together or use an _ or something else to join them up.

Also please wrap your code in [code[/code] tags.

katCT
12-04-2005, 11:56 PM
how do I put my code in code tags?

brad211987
12-05-2005, 04:17 PM
There are buttons when posting that will put code tags in for you or just type them in yourself by typing {CODE}{/CODE} but change {} to [].

And what language is your program in?

katCT
12-05-2005, 06:54 PM
thanks
my program is for a java class. I'm not really sure what you mean by what code. I have a terrible teacher and at this point I'm just trying to pass the class.
Thank you so much for trying to help me!!!!

brad211987
12-06-2005, 01:58 AM
I apoligize if it offends you, but there are very very many small mistakes in this program. I believe however that you have the logic correct. The main problem is basic things like spaces between variables, and the placement of the constructors etc....

If you would like, email me at bjg21@uakron.edu and I can discuss more of it with you. I copied and pasted it down to my computer and I'm going to just work on formatting things to make it easier to read and work with.