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
igor_vitrenko [27]
2 years ago
13

C++ :Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the outpu

t is either heads or tails. Assume the input is a value greater than 0. If the input is 3, the output is:a.headsb.tailsc.headsFor reproducibility needed for auto-grading, seed the program with a value of 2. In a real program, you would seed with the current time, in which case every program run output would be different, which is what is desired but can't be auto-graded. Your program must define and call a function: string HeadsOrTails() that returns "heads" or "tails".
NOTE: A common student mistake is to call srand() before each call to rand(). But seeding should only be done once, at the start of the program, after which rand() can be called any number of times.
Computers and Technology
1 answer:
yaroslaw [1]2 years ago
3 0

Answer:

#include <iostream>

#include <cstdlib>

using namespace std;

int t;

char HeadsOrTails(){

char a='h';

char b='t';

if(t%2==0)

return a;

else

return b;

}

int main ()

{

 int n,  c, b;

   

 cout << "Enter the number of decisions you want" << endl;

 cin >> n;

 b=1;

 cout << "Decisions are:" << endl;

  srand(100);

 for (c = 1; c <= n; c++)

 {

   

   t = rand();

   if(HeadsOrTails()=='h'){

    cout<<b<<".heads"<<endl;

    b++;

   }

   else{

    cout<<b<<".tails"<<endl;

    b++;

   }

   

 }

 return 0;

}

Explanation:

random number generator is used to generate a number and then heads and tails is decided on even and odd number basis. if number is even then decision is head and if number is odd then decision in tails

You might be interested in
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
2 years ago
The domains of the risk IT framework mutually inform each other, creating flexibility and agility. It is possible to uncover a p
Andrej [43]

Answer:

The best option is A).True

Explanation:

This is because, according to the statement, it is possible to uncover a potential threat in the risk governance domain and quickly assess its impact using the risk evaluation domain in an IT environment. The risk IT framework is used in an IT environment for security of domains, the business involved, etc.

6 0
2 years ago
Write a method called justFirstAndLast that takes a single String name and returns a new String that is only the first and last
NemiM [27]

Answer:

Answer is in the attached screenshot.

Explanation:

Using regex to split a given input string via whitespace, then returns the first and last element of the array.

6 0
2 years ago
Cathy connected a keyboard, mouse, and printer to her computer through a Bluetooth connection. What type of network has she crea
Zielflug [23.3K]

The answer to the given question is (B) PAN.

A PAN (personal area network) connection is <u>a network used for interconnecting devices centered on a person’s workspace</u>. Bluetooth is a type of wireless PAN. Bluetooth-based wireless PAN connection is also called a <em>piconet</em>. Other examples of PAN that is not wireless based include a USB drive.

4 0
2 years ago
Read 2 more answers
Write the prototype for a function named showValues. It should accept an array of integers and an integer for the array size as
aalyn [17]

Answer:

void showValues(int [<em>maximum</em><em> </em><em>volume</em>],int);

4 0
2 years ago
Read 3 more answers
Other questions:
  • A mouse is known as a _____ device that is able to detect motion in relation to the surface and provides an onscreen pointer rep
    6·1 answer
  • 5.William travels a lot on business purpose. He needs to regularly communicate with his business partner. He also needs to send
    15·1 answer
  • Need 2.5 Code Practice Answers
    14·2 answers
  • When TCP/IP translates a network layer address into a data link layer address, it sends a special ____________ to all computers
    15·2 answers
  • Consider the following classes:
    8·1 answer
  • The elements of an integer-valued array can be initialized so that a[i] == i in a recursive fashion as follows: An array of size
    10·1 answer
  • Write a program that lets a user enter N and that outputs N! (N factorial, meaning N*(N-1)*(N-2)*..\.\*2*1). Hint: Initialize a
    5·1 answer
  • In Java please.
    12·1 answer
  • 4. Word Separator:Write a program that accepts as input a sentence in which all of thewords are run together but the first chara
    10·1 answer
  • The microprogram counter (MPC) contains the address of the next microcode statement for the Mic1 emulator to execute. The MPC va
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!