Results 1 to 7 of 7
  1. #1
    madkidd02 is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Lightbulb [SOLVED] Help =] .

    hey everyone. im new to the forum. ok im a total noob wen it comes to this. im majoring in computer science and i was doing some class work today and i came across this
    --------------------------------------------------------------------------

    import java.util.Scanner; //Needed for the scanner class

    /**
    *this program demonstrates a user controlled loop
    */

    public class TestAverage1
    {
    public static void main(String[] args);
    {
    int score1, score2, score3; // three test scores
    double average; // Average test score
    char repeat; // To hold 'y' or 'n'
    String input; // To hold input

    System.out.println("this program calculates the " +
    "average of three test scores.");

    // Creat a scanner object for keyboard input.
    Scanner keyboard = new Scanner (System.in);

    // Get as many sets of tet scores as the user wants.
    do
    {
    // Get the first test score in this set.
    System.out.print("Enter score #1:");
    score1 = keyboard.nextInt();

    // Get the second test score in this set.
    System.out.print("Enter score #2:");
    score2 = keyboard.nextInt();

    // Get the Third test score in this set.
    System.out.print("Enter score #3:");
    score3 = keyboard.nextInt();

    // consume the remaining newline.
    keyboard.nextLine();

    // Calculate and print the average test score.
    average = (score1 + score2 + score3) / 3.0;
    System.out.println("The average is" + average);
    System.out.println(); //Prints a blank line

    //Does the user want to average another set?
    System.out.println("would you like to average" + "another set of test scores?");
    input = keyboard.nextLine(); // Read a line.
    repeat = input.charAt (0); // Get the first char.

    } while (repeat == 'Y' || repeat == 'Y');
    }
    }
    --------------------------------------------------------------------------

    i tryed to compile it and i get 1 error. the little arrow points to the "m" in "main" at the begining of the code. i tryed posting a link but you cant until u have more than 20 post's

    anyways . i asked my prof. about it and he wasnt sure wat it is either. he thinks its because the jdk is old and the computers need to b updated. he told me to see if i can figure out the problem. im not asking for you guys to do it for me. im asking anyone if theres any suggestion to what can it be or if someone has the answer they can give it to me too instead of torturing me lol =]

    thanks in advance

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Error please...

    Please post the error message you get when compiling
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    delete "dot-comma" at the end of declaring the main method:
    Java Code:
    public static void main(String[] args){

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,463
    Rep Power
    25

    Default

    @serjant:
    All you guys that speak our language so well put a lot of us to shame that only know English.
    So don't take it badly if I call the "dot-comma" a semi-colon.
    Is that a literal translation or ???

  5. #5
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Good to know about semicolon, knowing four languages (Hebrew,German,English,Russian) is not very easy stuff,so i think i mixed something with thetranslation. Thanks for correcting me.

  6. #6
    madkidd02 is offline Member
    Join Date
    Oct 2008
    Posts
    3
    Rep Power
    0

    Default

    Thanks serjant. it was the semi-colon that was messing the program up. now the program works perfectly fine. once again thanks =]

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •