I cannot see results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lotus18
    Contributor
    • Nov 2007
    • 865

    I cannot see results

    Hello World

    I made a simple program on creating new objects (student1 and student2). I compiled it and it is OK, but when I run it, I don't see results. I tried to insert from Line#4 to Line#36 after Line#2 but I'm getting compile error. Please guide me.

    >>>Shifting to Java now : )

    [CODE=java]public class student{
    public static void main(String args[]){
    }
    String student_id;
    String lastname;
    String firstname;
    String address;
    int score=0;
    void get_student_id( String adStudentId){
    student_id=adSt udentId;
    }

    void getlastname(Str ing adLastName){
    lastname=adLast Name;
    }

    void getfirstname(St ring adFirstName){
    firstname=adFir stName;
    }

    void getaddress(Stri ng adAddress){
    address=adAddre ss;
    }

    int totalscore(int score1, int score2, int score3){
    score=score1+sc ore2+score3;
    return score;
    }

    void printoutput(){
    System.out.prin tln("studentid: " + student_id);
    System.out.prin tln("lastname: " + lastname);
    System.out.prin tln("firstname: " + firstname);
    System.out.prin tln("address: " + address);
    System.out.prin tln("totalscore : " + score);
    }

    }
    class bscs extends student{
    public static void main(String args[]){
    // int r=
    student student1=new student();
    student student2=new student();

    student1.get_st udent_id("2004-01287");
    student1.getlas tname("caƱeso") ;
    student1.getfir stname("reysean ");
    student1.getadd ress("upper calarian, zamboanga city");
    student1.totals core(30, 45, 75);

    student2.get_st udent_id("2005-23652");
    student2.get_st udent_id("marav illa");
    student2.get_st udent_id("eunic e");
    student2.get_st udent_id("bonif acio, davao city");
    student1.totals core(30, 45, 75);

    student1.printo utput();
    student2.printo utput();
    }

    }[/CODE]

    Rey Sean
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    You have an empty main(String[] args) { } method.

    kind regards,

    Jos

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      Yes, I know it is empty. But as just like what I said in post#1, I cut the codes from line#4 to line #36 and inserted it after line #2 but I am getting compile error. How can I solve this and why am I getting an error?

      Rey Sean

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by lotus18
        Yes, I know it is empty. But as just like what I said in post#1, I cut the codes from line#4 to line #36 and inserted it after line #2 but I am getting compile error. How can I solve this and why am I getting an error?

        Rey Sean
        I am very sure that your compiler didn't just say "compiler error". It gave you the
        line number and the text on the line as well as a descriptive text about the error
        it had diagnosed. You have seen (and hopefully read) that text. We are not psychic
        so why do you want us to guess?

        kind regards,

        Jos

        Comment

        • hsn
          New Member
          • Sep 2007
          • 237

          #5
          you should post the error description as Jos said.

          and how can you execute a code without something in the main methode????

          regards

          hsn
          Last edited by hsn; Apr 12 '08, 12:38 PM. Reason: i didn't see something

          Comment

          • sukatoa
            Contributor
            • Nov 2007
            • 539

            #6
            Hello rey.... You forgot to remove your method main in student since your main class is in bscs..... and you extend the student class in bscs...

            since you create an object from student class, your bscs should be the main class....

            You must implement the bscs class in public.... and remove the public in student ( public class student ) if you like to compile it in a file....

            You can still have that public in student if you save it in another file student.java... .

            based on the code @ original post...

            try it bro....
            sukatoa

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Well if the OP doesn't want to show us the code that's giving problems, I'm not
              going to play editor and change some other code according to some directions
              to what the OP had in mind. If someone wants to have his/her problem solved by
              us, that someone should give clear descriptions of the problem and the actual
              code that gives those problems. This is not a guessing game. I'm out of here.

              kind regards,

              Jos

              Comment

              • lotus18
                Contributor
                • Nov 2007
                • 865

                #8
                Originally posted by JosAH
                I am very sure that your compiler didn't just say "compiler error". It gave you the
                line number and the text on the line as well as a descriptive text about the error
                it had diagnosed. You have seen (and hopefully read) that text. We are not psychic
                so why do you want us to guess?

                kind regards,

                Jos
                Sorry for the trouble Joash.

                To sukatoa, thanks bro. Now I got it. 'Till next time. : )

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by lotus18
                  .. 'Till next time. : )
                  ... and hopefully you will follow Jos' advice when you do post "next time".

                  Comment

                  • lotus18
                    Contributor
                    • Nov 2007
                    • 865

                    #10
                    Originally posted by r035198x
                    ... and hopefully you will follow Jos' advice when you do post "next time".
                    Yes r035198x. Have a niceday!

                    Rey Sean

                    Comment

                    Working...