1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
goblinko [34]
3 years ago
7

Monster Collector

Computers and Technology
1 answer:
Lera25 [3.4K]3 years ago
5 0

Answer:

In java:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int monsternum, usernum;

 int count = 0;

 Random rand = new Random();

 String [] monsters = {"wild pikamoo","wild bulbaroar"};

 for(int i =0;i<2;i++){

     monsternum = rand.nextInt(5);  

     System.out.print("A "+monsters[i]+" appears! Guess a number between 1 and 5: ");

     usernum = input.nextInt();

     if(monsternum == usernum){      count++;      System.out.println("Congratulations, you caught a "+monsters[i]+"!");  }

 else{      System.out.println("You almost had it, but the monster escaped.");  }

 

 }

 System.out.println("There are no more monsters to encounter!");

 System.out.println("You caught "+count+" monsters of 2");

 if(count!=2){      System.out.print("Keep training to be the very best!");  }

 else{      System.out.print("You're the monster collector master!");  }

}

}

Explanation:

This declares monster and user number as integers

 int monsternum, usernum;

Initialize count to 0

 int count = 0;

Call the random object

 Random rand = new Random();

Create a string array to save the monster names

 String [] monsters = {"wild pikamoo","wild bulbaroar"};

Iterate for the 2 monsters

 for(int i =0;i<2;i++){

Generate a monster number

     monsternum = rand.nextInt(5);  

Prompt the user to take a guess

     System.out.print("A "+monsters[i]+" appears! Guess a number between 1 and 5: ");

Get user guess

     usernum = input.nextInt();

If monster number and user guess are equal, congratulate the user and increase count by 1

<em>      if(monsternum == usernum){      count++;      System.out.println("Congratulations, you caught a "+monsters[i]+"!");  } </em>

If otherwise, prompt the user to keep trying

<em>  else{      System.out.println("You almost had it, but the monster escaped.");  }  </em>

<em>  } </em>

Print no monsters again

 System.out.println("There are no more monsters to encounter!");

Print number of monsters caught

 System.out.println("You caught "+count+" monsters of 2");

Print user score

<em>  if(count!=2){      System.out.print("Keep training to be the very best!");  } </em>

<em>  else{      System.out.print("You're the monster collector master!");  } </em>

You might be interested in
Which activity represents a violation of the licensing agreement?
Lena [83]
A) <span>unauthorized duplication of software </span>
6 0
3 years ago
Read 2 more answers
An argument does not always have to be made in words. A piece of music
mixas84 [53]

Answer:

B. emotional

Explanation:

An emotional argument. An argument does not always have to be made in words.

4 0
3 years ago
3. This shows you the different things that all the tools can do, as you click on the tools
leva [86]
D that’s the answer I learn that in my old school
7 0
3 years ago
Which country has the most common features of analogue and digital computer​
ANTONII [103]

Explanation:

i don't think rhis question could be..

4 0
3 years ago
A virus that propagates using the internet or another computer network is called __________.
olasank [31]
This is called a worm
8 0
3 years ago
Other questions:
  • The process of engineering design typically starts with what ?
    12·1 answer
  • What steps should Jeremy take to get himself motivated to study for the test?
    12·2 answers
  • The Knowledge Consistency Checker (KCC) ensures the maximum number of hops between any two domain controllers does not exceed wh
    12·1 answer
  • When a Python program is reading a file, the data is input as plain ASCII characters in a string. What is the following code doi
    15·1 answer
  • Contains the instructions your computer or device needs to run programs and apps
    5·1 answer
  • how write a program to prompt the user for hours and rate per hour using input to computer gross pay Use 35 hours and rate2.75 p
    9·1 answer
  • Which type of system is used to analyze, evaluate, and integrate the output of other systems?
    5·2 answers
  • . Which of the following is NOT a valid declaration for a character string?
    6·1 answer
  • Who is the father of computer?​
    6·1 answer
  • Que significa WWW en informática ._.​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!