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
PolarNik [594]
3 years ago
6

In the simulation, player 2 will always play according to the same strategy. The number of coins player 2 spends is based on wha

t round it is, as described below. (a) You will write method getPlayer2Move, which returns the number of coins that player 2 will spend in a given round of the game. In the first round of the game, the parameter round has the value 1, in the second round of the game, it has the value 2, and so on. The method returns 1, 2, or 3 based on the following rules. If round is divisible by 3, then return 3. If round is not divisible by 3 but is divisible by 2, then return 2. If round is not divisible by 3 and is not divisible by 2, then return 1. Complete method getPlayer2Move below by assigning the correct value to result to be returned.
Computers and Technology
1 answer:
baherus [9]3 years ago
8 0

The simulation, player 2 will always play according to the same strategy.

Method getPlayer2Move below is completed by assigning the correct value to result to be returned.

Explanation:

  • You will write method getPlayer2Move, which returns the number of coins that player 2 will spend in a given round of the game. In the first round of the game, the parameter round has the value 1, in the second round of the game, it has the value 2, and so on.

#include <bits/stdc++.h>  

using namespace std;

bool getplayer2move(int x, int y, int n)  

{

   int dp[n + 1];  

   dp[0] = false;  

   dp[1] = true;  

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

       if (i - 1 >= 0 and !dp[i - 1])  

           dp[i] = true;  

       else if (i - x >= 0 and !dp[i - x])  

           dp[i] = true;  

       else if (i - y >= 0 and !dp[i - y])  

           dp[i] = true;  

       else

           dp[i] = false;  

   }  

   return dp[n];  

}  

int main()  

{  

   int x = 3, y = 4, n = 5;  

   if (findWinner(x, y, n))  

       cout << 'A';  

   else

       cout << 'B';  

   return 0;  

}

You might be interested in
Write a program that determines the value of the coins in a jar and prints the total in dollars and cents. Read integer values t
Shalnov [3]

Answer:

The programming language is not stated. To answer this question, I'll make use of python programming language.

<em>The following units of conversions is used in this program</em>

<em>1 quarter = $0.25</em>

<em>1 dime = $0.10</em>

<em>1 nickel = $0.05</em>

<em>1 penny = $0.01</em>

<em>$1 = 100 cents</em>

This program makes use of few comment (See explanation for line by line explanation)

Having listed the above, the program is as follows:

#prompt user for inputs

quarters = int(input("Number of Quarters: "))

dimes = int(input("Number of Dimes: "))

nickels = int(input("Number of Nickels: "))

pennies = int(input("Number of Pennies: "))

#Convert coins to dollars

dollar = 0.25 * quarters + 0.10 * dimes + 0.05 * nickels + 0.01 * pennies

print("Dollar Equivalent")

print(str(round(dollar,2))+" dollars")

cent = dollar * 100

print("Cent Equivalent")

print(str(round(cent,2))+" cents")

Explanation:

This first line is a comment

#prompt user for inputs

This line prompts user for value of quarters in the jar

quarters = int(input("Number of Quarters: "))

This line prompts user for value of dimes in the jar

dimes = int(input("Number of Dimes: "))

This line prompts user for value of nickels in the jar

nickels = int(input("Number of Nickels: "))

This line prompts user for value of pennies in the jar

pennies = int(input("Number of Pennies: "))

Using the coin conversion listed in the answer section, the user inputs is converted to dollars in the next line

dollar = 0.25 * quarters + 0.10 * dimes + 0.05 * nickels + 0.01 * pennies

The string "Dollar Equivalent" is printed using the next line

print("Dollar Equivalent")

This line prints the dollar equivalent of the converted coins

print(str(round(dollar,2))+" dollars")

Using the coin conversion listed in the answer section, the user inputs is converted to cents in the next line

cent = dollar * 100

The string "Cent Equivalent" is printed using the next line

print("Cent Equivalent")

This line prints the cent equivalent of the converted coins

print(str(round(cent,2))+" cents")

Please note that the dollar and cent equivalents are rounded to two decimal places. Even though, it's not a requirement of the program, it's a good programming practice

7 0
4 years ago
How can you check data on devices connected through an iot network?
vampirchik [111]

<em>Internet of Things(IoT)</em> which could be described as a group of interconnected systems or objects which are able to communicate, transmit and exchange data using <em>smart technology</em> and sensors. Data can be checked and monitored on these devices using Dashboards.

  • Dashboards provides a graphical representation of information about interconnected IoT objects or devices. They are produced using data collected from interconnected objects.

  • Since all objects are interconnected, devices use data which are are stored in storage or memory locations. These data are then used to prepare information displayed on dashboards.

Therefore, dashboards provides an interface to view data information about IoT connected devices.

Learn more :brainly.com/question/24958568

6 0
3 years ago
Read 2 more answers
Required skills,training,education for dentist
AlekseyPX

Answer:

Education-Bachelor's degree prior to admission to dental school; doctoral degree in dental medicine or dental surgery; some dental specializations require completion of a residency

Skills- Communication skills. Dentists must have excellent communication skills, Detail oriented, Dexterity, Leadership skills, Organizational skills, Patience, Physical stamina, Problem-solving skills.

Explanation:

7 0
3 years ago
In an input file, what maintains the location of the next item that will be read from the file?
Semmy [17]

The Read Position marks the location of the next item that will be read from the file.

6 0
4 years ago
What process makes one group a member of another group? nesting cloning copying grouping
Mumz [18]

Answer: Nesting

Explanation: The process of making one group the part of another group is defines as nesting. it is mostly done in the programming . This process helps in reduction of the program by nesting the functions. Nesting is done in computer field in applications as well to make one document the part of other  document .Therefore, nesting is the correct option .

8 0
3 years ago
Other questions:
  • a problem exists when the current condition differs from a desired condition. This idea defines which step in problem-solving?
    13·2 answers
  • What was the benefit of a caloytpe over a daguerreotype
    6·2 answers
  • The icacls.exe command adds __________, which are visible by clicking the Advanced button in the folder Properties dialog box
    15·1 answer
  • Introduction to graphic design please help! Define the four terms: design ,art,decoration , and visual literacy. Describe how th
    12·1 answer
  • A range of cells can be converted into an Excel ________ so that the data can be analyzed
    7·1 answer
  • In a series circuit, electrons only flow along one path. Given this information, which of the following is an advantage of serie
    15·2 answers
  • Connie decided that her paper should be organized in the order in which the events happened. What type of organizational method
    15·1 answer
  • 2.2-2 Consider sorting numbers stored in array by first finding the smallest element n A of and exchanging it with the element i
    11·1 answer
  • ¿ cuales son las características de revolución industrial?
    11·1 answer
  • The cpu stores the results of computations in ________.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!