#hello I couldn't really understand where the errors are in this, I felt like I had everything right

8 messages · Page 1 of 1 (latest)

short vector
#

So, I just put my whole thing in here and I'm very new to programming using Java, I dont really understand what I did wrong here since I cant get it to run

public class ProgramFixing {

public static void main(String[] args) {
    // TODO code application logic here
    // The program should read in one floating-point value and
    // three integer values from the user.
    // The floating-point value should be stored in the variable
    // factor, and the integer values in the variables firstScore, secondScore,
    // and thirdScore, respectively. The program should print out the three values entered.
    // Then, the program should calculate the quantity
    // (thirdScore + factor * (firstScore + secondScore)) / (2 * factor + 1)
    // and store it in the variable weightedScore.
    // The program should then print out the value of weightedScore.

    Scanner scan = new Scanner(System.in);

    int firstScore;
    int secondScore
    int thirdScore;

    System.out.print("Enter the factor: ");
    factor = scan.nextInt();
    System.out.print("Enter the first score: ");
    firstScore = scan.nextInt();
    System.out.print("Enter the second score: ");
    secondscore = scan.nextInt();
    System.out.print("Enter the third score: ");
    thirdScore = scan.nextInt();

    System.out.println("The factor is " + factor);
    System.out.println("The three scores are\t" + firstScore, "\t" + secondScore + \t + thirdScore);
        
    int weightedScore = (thirdScore + factor * firstScore + secondScore / 2 * factor + 1);

    System.out.println("The value of the result is " + weightedScore);

}

}

tranquil karmaBOT
#

This post has been reserved for your question.

Hey @short vector! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

stark mica
#

Where are you initializing the factor variable

worthy drum
#

What do you mean you can’t get it to run? What error do you get?

stark mica
#

I don’t see anywhere where you have say int factor;

crystal abyss
#

well I don't know if this is a typo or what but you're missing a semicolon at "int secondScore", and also in this line
System.out.println("The three scores are\t" + firstScore, "\t" + secondScore + \t + thirdScore);
you are missing quotations around \t.

also for your convenience you can declare all three int variables together, like this:
int firstScore, secondScore, thirdScore;

hidden python
#

or you could also omit the predeclarations and do int firstScore = scan...; directly