Computer Science, asked by tiebreakerx, 2 months ago

I have been trying to create a minigame for two people to play in Bluej. It will be as following:

The game asks you at the begin, how many rounds you would like to play. After you enter a number which will be the amount of rounds. Each round a question like this is asked: How much is (number1 + number2)? And then you enter the number. If it is correct, the game tells you that it is correct and gives you one point. If it is not correct, the game tells you that it was not correct and tells you the right answer.

Answers

Answered by jeromeseejo73
1

Answer:

import java.util.Scanner;

public class minigame

{

public static void main(String[] args)

{

 Scanner sc=new Scanner(System.in);

 System.out.println("\t\t\t\tTHIS IS A 2 PLAYER GAME");

 System.out.print("HOW MANY ROUNDS WOULD YOU LIKE TO PLAY?? : ");

 int rounds=sc.nextInt();

 //i am giving 2 random integers between 0 to 200,okay

 int range=(200-0)+1;

 for(int i=1;i<=rounds;i++)  

 {

  int rand=(int)(Math.random()*range+0);

  int num1=rand,num2=rand+rand-100;

  System.out.println("HOW MUCH IS..");

  System.out.print(num1+"+"+num2+" :");

  int ans=sc.nextInt();

  if(ans==(num1+num2))  

   System.out.println("Your answer is correct :)");

  else  

  {

   System.out.println("THE CORRECT ANSWER IS:"+(num1+num2));

   System.out.println("CORRECT YOUR MISTAKE NEXT TIME");

  }

 }

}

}

Explanation:

Similar questions