#Incorrect Output

8 messages · Page 1 of 1 (latest)

foggy flume
#

Hello, I need this to be checked rough thoroughly and it keeps giving me 2 results instead of 1 each and what changes I need to do.

My questions are:

• Question 1: What is the acronym for School? Answer GCHSS
• Question 2: How many different buildings/blocks are there in this school? Answer 5
• Question 3: This school includes a football ground on its premises. Answer true ```

Incoming long coding  as taking a screenshot won't fit !

``` import java.util.Scanner;
public class CMPTTask2{
 public static void main (String args[]){
  // Declaring Correct Count
  int correctCount = 0;
  
  // Entering the input according to the quiz
  // Question 1
  Scanner input = new Scanner (System.in);
  System.out.println("Question 1: What is the acronym for School?");
  String SCHL = input.nextLine();
  if(SCHL.equals("GCHSS")) {
  System.out.println("\nCorrect!");
  correctCount++;
  }
  else {
  System.out.println("\nWrong!");
  }
  
  // Question 2
  System.out.println("Question 2: How many different buildings/blocks are there in this school?");
  String num = input.nextLine();
  if(num.equals("5")) {
  System.out.println("\nCorrect!");
  correctCount++;
  }
  else { 
  System.out.println("\nWrong!");
  }
  
  // Question 3
  System.out.println("Question 3: This school includes a football ground on its premises");
  String statement= input.nextLine();
  if(statement.equals("true")) {
  System.out.println("\nCorrect!");
  correctCount++;
  }
  else { 
  System.out.println("\nWrong!");
  }
  
  // Results
  if (correctCount==correctCount) {
  System.out.println("\nYou are a winner" + correctCount + "/3");
  }
  
  if (correctCount>=3) {
  System.out.println("\nYou did well" + correctCount + "/3");
  }
  else {
   System.out.print(correctCount>=3);
   }
  
   if (correctCount != 3) {
  System.out.println("\nYou can do better" + correctCount + "/3");    
  }
 }
} ```
naive yewBOT
#

Hey, @foggy flume!
Please remember to /close this post once your question has been answered!

foggy flume
foggy flume
# foggy flume
• Displays the above questions.
• Accepts answers from the user.
• Assigns 1 mark for each correct answer.
• Deducts 1 mark for each incorrect answer.
• Display “You are a winner” if the total mark is 3/3
• Display “You did well” if the total mark is between 1/3.
• Display “You can do better” if the total mark is negative. ```
analog jungle
#

if (correctCount==correctCount) will always be true.

#

you just need to check all your IF statements, because they are not checking the correct count.

foggy flume
#

Alright thanks!