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
Explain the working principle of computer? can anyone tell​
Crazy boy [7]

Answer:

input process and output hehe

4 0
3 years ago
When the + operator is used with strings, it is known as the?
Darya [45]
Concatenation, which mean we combine two or more strings into one.
5 0
3 years ago
Create a string called alphabet containing 'abcdefghijklmnopqrstuvwxyz', then perform the following separate slice operations to
spin [16.1K]

Answer:

There is no short answer.

Explanation:

First let's create the string:

  • alphabetString = "abcdefghijklmnopqrstuvwxyz";

The first half of the string using slice method can be written as:

  • alphabetString.slice(0, 13);

The first half of the string using only the ending index can be written as:

  • alphabetString.slice(-13);

When we put - at the start of the index number, the counting begins at the last element with -1 and goes backwards.

The second half of the string can be written as:

  • alphabetString.slice(13,26);

The second half of the string using only the starting index can be written as:

  • alphabetString.slice(13);

To get the every second letter in the string, we need a for loop:

  • for( let x = 0; x < alphabetString.length(); x = x + 2){

                 alphabetString.slice(x);

}

To get the entire string in reverse, we can use the reverse method that is built-in:

  • alphabetString.reverse();

To get the every third letter of the string, we can again use a for loop:

  • for( let x = -1; x = -27; x = x - 3){

                  alphabetString.slice(x);

}

I hope this answer helps.

7 0
3 years ago
Carly’s Catering provides meals for parties and special events. Write a program that prompts the user for the number of guests a
Savatey [412]

Answer:

Answered below

Explanation:

Scanner n = new Scanner(System.in);

System.out.print("Enter number of guests: ");

int numOfGuests = n.nextline();

double pricePerGuest = 35.0;

double totalAmount = numOfGuests * pricePerGuest;

String event = " ";

if ( numOfGuests >= 50){

event = "Large event";

}else{

event = "small event";

}

System.out.print(numOfGuests);

System.out.println(pricePerGuest);

System.out.println( totalAmount);

System.out.println(event);

6 0
3 years ago
Some companies, especially consulting firms, require their employees to create ____ about sessions with clients.
Cloud [144]

Answer: Reports

Explanation:

 Some companies always ask to the employees to create the particular report for the session with their clients.

As, the report is the main communication channel between the company employees and clients where all the information are complied together and focus for transmitting the data clearly.

Efficient reports are basically help in the decision making and problem with sufficient knowledge.  

On the other hand, all the other options are not needed for session with the clients in the organization. Therefore, report is the correct option.

 

3 0
3 years ago
Other questions:
  • It is important that data being imported from a text file into access are separated by a character, such as a comma, which defin
    8·1 answer
  • What is typically unique in each database table?
    5·2 answers
  • Camera lenses typically have very long focal points. true or false.
    5·2 answers
  • To plan a pizza party, one may want to order enough pizza for everyone. Use the slicesPerPizza, slicesPerGuest, and totalGuests
    11·1 answer
  • Write a game that plays many rounds of Rock Paper Scissors. The user and computer will each choose between three items: rock (de
    8·1 answer
  • Pls answer i need to turn it in today!!
    15·1 answer
  • Define a function compute_gas_volume that returns the volume of a gas given parameters pressure, temperature, and moles. Use
    12·1 answer
  • Simple interest will always pay more interest than compound interest.
    14·1 answer
  • UPS or FedEx plays what role in the supply?
    9·1 answer
  • Why is it important to register your software when you install it
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!