answer.
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
katrin2010 [14]
1 year ago
12

In a certain game, a player may have the opportunity to attempt a bonus round to earn extra points. In a typical game, a player

is given 1 to 4 bonus round attempts. For each attempt, the player typically earns the extra points 70% of the time and does not earn the extra points 30% of the time. The following code segment can be used to simulate the bonus round.
success - 0
attempts - RANDOM 1, 4
REPEAT attempts TIMES
IF (RANDOM 110 s 7
success - success + 1
DISPLAY "The player had"
DISPLAY attempts
DISPLAY "bonus round attempts and"
DISPLAY success
DISPLAY "of them earned extra points."
Which of the following is not a possible output of this simulation?
А. The player had 1 bonus round attempts and 1 of them earned extra points.
B The player had 2 bonus round attempts and of them earned extra points.
С The player had 3 bonus round attempts and 7 of them earned extra points.
D The player had 4 bonus round attempts and 3 of them earned extra points.
Computers and Technology
1 answer:
Assoli18 [71]1 year ago
8 0

Answer:

С The player had 3 bonus round attempts and 7 of them earned extra points.

Explanation:

Given

See attachment for correct code segment

Required

Which of the options is not possible?

From the question, we understand that:

attempts \to [1,4] --- attempt can only assume values 1, 2, 3 and 4

The following "if statement" is repeated three times

<em>IF RANDOM[1,10] <= 7:</em>

<em>    success = success + 1</em>

This implies that the maximum value of the success variable is 3

The first printed value is the attempt variable

The second printed value is the success variable.

From the list of given options, (a), (b) and (d) are within the correct range of the two variable.

While (c) is out of range because the value printed for variable success is 7 (and 7 is greater than the expected maximum of 3)

You might be interested in
Which of the following would not be considered metadata for a spreadsheet file?
Genrish500 [490]

Answer:

B.

Explanation:

Metadata is a type of data that dispense details of other data. In simple terms, metadata can be defined as information of a file such as file name, attributes, etc.

<u>In excel sheet, metadata works the same and helps to provide information about </u><u>file name, author name, file size, attributes such as read-only, archieve, hidden, system, location of the file, date and time of creation, modification, or accessed, type of file, etc</u><u>.</u>

From the given options, the information that is not considered or included in metadata is calculation inside the file. Metadata in excel sheet does not include calculations inside the file. Thus option B is the correct answer

7 0
2 years ago
A Color class has three int color component instance variables: red, green, and blue. Write a toString method for this class. It
ELEN [110]

Answer:

public String toString() {

return "#(" + red + "," + green + "," + blue + ")";

}

Explanation:

The code:

public String toString() {

return "#(" + red + "," + green + "," + blue + ")";

}

Is a tostring java code, and it is so easy to write one, as compare to other programming languages

Writing a tostring method returns a strinb representation of an object in Java. Normally, the toString method returns the name of the object’s class plus its hash code.

This code creates a new colour object; then the result of its toString method is printed to the console.

Tostring method can be override. The default implementation of toString isn’t very useful in most situations. So, one can just override it.

8 0
2 years ago
Write a function named file_stats that takes one string parameter (in_file) that is the name of an existing text file. The funct
Ivan

Answer:

Here is the Python program.

characters = 0

words = 0

lines = 0

def file_stats(in_file):

   global lines, words, characters

   with open(in_file, 'r') as file:

       for line in file:

           lines = lines + 1

           totalwords = line.split()

           words = words + len(totalwords)

           for word in totalwords:

               characters= characters + len(word)

file_stats('created_equal.txt')

print("Number of lines: {0}".format(lines))

print("Number of words: {0}".format(words))

print("Number of chars: {0}".format(characters))

   

Explanation:

The program first initializes three variables to 0 which are: words, lines and characters.

The method file_stats() takes in_file as a parameter. in_file is the name of the existing text file.

In this method the keyword global is used to read and modify the variables words, lines and characters inside the function.

open() function is used to open the file. It has two parameters: file name and mode 'r' which represents the mode of the file to be opened. Here 'r' means the file is to be opened in read mode.

For loop is used which moves through each line in the text file and counts the number of lines by incrementing the line variable by 1, each time it reads the line.

split() function is used to split the each line string into a list. This split is stored in totalwords.

Next statement words = words + len(totalwords)  is used to find the number of words in the text file. When the lines are split in to a list then the length of each split is found by the len() function and added to the words variable in order to find the number of words in the text file.

Next, in order to find the number of characters, for loop is used. The loop moves through each word in the list totalwords and split each word in the totalwords list using split() method. This makes a list of each character in every word of the text file. This calculates the number of characters in each word. Each word split is added to the character and stored in character variable.

file_stats('created_equal.txt')  statement calls the file_stats() method and passes a file name of the text file created_equal.txt as an argument to this method. The last three print() statements display the number of lines, words and characters in the created_equal.txt text file.

The program along with its output is attached.

6 0
2 years ago
Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
blondinia [14]

Answer:

1) Nate open his template first and clicks the tab on the ribbon

2) Then, he clicks the dialog box that appears

3) He chooses Templates from the menu

4) Clicks Go to clicks the Organizer button

5) Then he clicks copy

6) Next he clicks on the left side to the backstage view

7) Finally, he selects the document that includes the style he wants to transfer to the normal template

Explanation:

I hope this helps

5 0
1 year ago
Two-dimensional random walk (20 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of
natka813 [3]

Answer:

The following code in the explanation does the job for you. Here I have made use of Random class of Java to generate random numbers.

Explanation:

Code:

import java.util.*;

class RandomWalker {

  public static void main(String args[]){

      int n = Integer.parseInt(args[0]);

      int x = 0;

      int y = 0;

      Random random = new Random();

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

          int tmp = random.nextInt(4);

          if(tmp == 0){

              x++;

          }

          if(tmp == 1){

              y++;

          }

          if(tmp == 2){

              y--;

          }

          if(tmp == 3){

              x--;

          }

          System.out.println("(" + x + "," + y + ")");

      }

      int distance = x*x + y*y;

      System.out.println("Squared Distance = " + distance);

  }

}

4 0
2 years ago
Other questions:
  • Modern operating system decouple a process address space from the machine's physical memory. list two advantages of this design.
    6·1 answer
  • Grabar microphone audio icon_person click each item to hear a list of vocabulary words from the lesson. then, record yourself sa
    7·2 answers
  • A computer’s memory is composed of 8K words of 32 bits each. How many bits are required for memory addressing if the smallest ad
    10·1 answer
  • Survey Q, Non-scoring: What role are you playing in your team?
    5·2 answers
  • assume that name is a variable of type stirng that has been assigned a value write an expression whose value is the last charact
    11·1 answer
  • Escribe, en los siguientes cuadros, los conceptos que correspondan
    10·1 answer
  • It has been said that the quality of our relationships depends in large part on the quality of our
    6·1 answer
  • 1. Create a view named customer_addresses that shows the shipping and billing addresses for each customer.
    15·1 answer
  • Which of the following has been a result of the increase in local organic farms?a decrease in farmers' markets
    10·2 answers
  • Joe wants to use an engaging image as a hook in his presentation , but he’s afraid of violating any copyright law. What should h
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!