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
The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of
mote1985 [20]

The program is correct: at the beginning, product = 0. Then, we start summing Y to that variable, and we sum Y exactly X times, because with each iteration we increase Count by 1, and check if Count=X so that we can exit the loop.

5 0
3 years ago
_______ allow(s) you to apply colorful, eye catching designs to a presentation all at once.
astraxan [27]

What are some options of answers, or is there none?


4 0
2 years ago
Read 2 more answers
Why is it important to recognize the proper boundaries or limits of algorithms?
Oduvanchick [21]

Answer:

D

Explanation:

DDDD no war\t

4 0
2 years ago
Create a bulleted list of four descriptive terms describing possible values a person may have. These may be your own values, or
Minchanka [31]
Create a bulleted list of four descriptive terms describing possible values a person may have.

* always be true to yourself
* honesty is the best policy
* making mistakes leads you to solutions
* it's ok to be wrong
7 0
3 years ago
JAVA
Leokris [45]

Answer:

Answer provided in screenshot, not really too happy with my implementation but it works.

Explanation:

Iterate through months, handling logic for every 12 months to get the raise.

8 0
2 years ago
Other questions:
  • A database administrator (DBA) must have a clear understanding of the fundamental business of an organization, be proficient in
    11·1 answer
  • Micheal has increased the contrast of the given picture. Which feature or menu option of a word processing program did he use? A
    15·1 answer
  • Which of the following data recording procedures is best used for behaviors that have a clear ending and beginning, do not occur
    12·1 answer
  • Theodor is researching computer programming. He thinks that this career has a great employment outlook, so he'd like to learn if
    9·2 answers
  • Python: Bad input on line 8. What is the fix, please can someone tell me I’m desperate?
    10·1 answer
  • 41. All the following software are examples of operating systems EXCEPT
    5·1 answer
  • How are actual rocket launches similar to how balloon rockets and canister rockets launch?
    6·1 answer
  • Define a function print_feet_inch_short(), with parameters num_feet and num_inches, that prints using ' and " shorthand. End wit
    6·2 answers
  • How would you use keywords and Boolean operators to help you with a web search?
    13·1 answer
  • Typically, hybrid drives use SSD to store the operating system and applications and hard disks to store videos, music, and docum
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!