I need help in this cod i have some error .. can you help me .

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sakinah1
    New Member
    • Nov 2013
    • 1

    I need help in this cod i have some error .. can you help me .

    public class Test

    {
    private double test1 = 0;
    private double test2 = 0;
    private double test3 = 0;
    private double average;
    // private double TestScore;

    {
    {
    public void Test (int Testnum )
    {
    TestNum = testnum;
    }
    }
    public void setTestScore(in t testnum, double testScore)
    {
    if(testnum == 1)
    {

    test1 = testScore;
    }
    else

    if(testnum == 2)
    {

    test2 = testScore;
    }
    else

    if(testnum == 3)
    {

    test3 = testScore;
    }

    }

    public double getTestScore (int testNum)

    {
    if(testNum==1)
    {

    TestScore = Test1;

    }
    else

    if(testNum ==2)
    {
    TestScore= test2;

    }
    else

    if(testNum ==3)
    {
    TestScore= test3;
    }
    return TestScore;

    }

    public double average ()
    {

    average =( Test[1] + Test[2] + Test[3])/3;
    return average;
    }

    public String toString()

    {

    String result;
    *result += "Test 1:\n" + getTestScore(1) + "\n";
    result += "Test 2:\n" + getTestScore(2) + "\n";
    result += "Test 3:\n" + getTestScore(3) + "\n";
    result += "average:\n " + average();

    return result;

    }
    }

    }
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    1.) Use code tags when posting code.
    2.) Don't say "I have some error". Read the error message that you got. What did it say? Post it here if you don't understand it. The error messages you get from the compiler are very important because they tell you what is wrong and how to fix it, so read them.

    Comment

    Working...