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
hram777 [196]
2 years ago
12

Higher Order Functions used for simulations of dice rolls. Definition: An n-sided dice function takes no arguments and always re

turns an int from 1 to n, inclusive. Types of n-sided dice functions: - Randomized: a randomized dice function can be fair, meaning that ir produce each possible outcome from 1 to n with equal probability. Examples: four_sided, six_sided - Deterministic: a deterministic dice function will be used for testing. Deterministic test dice functions always cycle through a fixed sequence of n values. - We write a make_fair_dice higher-order function to return a fair, randomized n-sided dice function. - We write a make_test_dice higher-order function that will return a deterministic, testing n-sided dice function.
Computers and Technology
1 answer:
tiny-mole [99]2 years ago
5 0

Answer:

#include <iostream>

#include <time.h>

#include <string>

using namespace std;

int main(){

srand(time(NULL));

cout<<"Throw dice"<<endl;

int b =0;

int a=0;

a=rand()%6;

b=rand()%6;

for (int i =0;i<1;i++)

{cout<<"dice one: "<<a<<endl;}

for (int i =0;i<1;i++)

{cout<<"dice two: "<<b<<endl;}

if(a>b)

{cout<<"first dice won"<<endl;}

if(b>a)

{cout<<"second dice won"<<endl;}

else{cout<<"they are same"<<endl;

return main();

}

return 0;

}

Explanation:

/*best dice roll game just for you change it as you want but all necessary things are there/*

You might be interested in
Match each logical function with its description. AND COUNTIF SUMIF IF tests for a certain condition and returns one of two valu
lakkis [162]
1. IF
2. AND
3. COUNTIF
4. SUMIF
4 0
3 years ago
Write a program that accepts two numbers R and H, from Command Argument List (feed to the main method). R is the radius of the w
nasty-shy [4]

Answer:

Answered below.

Explanation:

#Answer is written in Python programming language

#Get inputs

radius = float(input("Enter radius in inches: "))

height = float(input("Enter height in feet: "))

#Convert height in feet to height in inches

height_in_inches = height * 12

#calculate volume in cubic inches

volume = 3.14 * (radius**2) * height_to_inches

#convert volume in cubic inches to volume in gallons

volume_in_gallons = volume * 0.00433

#output result

print (volume_in_gallons)

7 0
2 years ago
Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/kmâ
zvonat [6]

Answer:

class Car(object):

   fuel = 0

   def __init__(self, mpg):

       self.mpg = mpg

   def drive(self, mile):

       if self.fuel * self.mpg >= mile:

           self.fuel -= mile / self.mpg

       else:

           print(f"get gas for your {self}")

       print(f"Fuel remaining: {self.fuel}")

   #classmethod

   def get_gas(cls):

       cls.fuel += 50

   #classmethod

   def add_gas(cls, gallon):

       if cls.fuel + gallon > 50:

           cls.fuel += 10

       else:

           cls.fuel += gallon

gulf = Car(20)

gulf.get_gas()

gulf.drive(200)

Explanation:

The Car class is defined in Python. Its drive method simulates the driving of a car with fuel that reduces by the miles covered, with efficiency in miles per gallon. The get_gas and add_gas methods fill and top up the car tank respectively.

3 0
2 years ago
Can you redact this image
spin [16.1K]

Answer:what???

Explanation:so

What

6 0
2 years ago
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
Other questions:
  • The following is true about SPAM ________.
    9·1 answer
  • PLEASE HELP ITS DRIVERS ED
    8·2 answers
  • Samantha plans an investigation in which she will study a population of animals. Which of these answers best describes the focus
    8·1 answer
  • A/an ___________ is a scheduling tool that sets the standard and nonworking time for the project and is used to assess how tasks
    6·1 answer
  • How to determine if the function f(x) = x^2 + 3 from real numbers to real numbers is Injective, surjective, or bijective
    13·1 answer
  • Which professionals can benefit from an understanding of statistics? Check all of the boxes that apply. magician trying to locat
    5·2 answers
  • A file name extension provides what information about a file?
    6·1 answer
  • Which of the following substances increases in quantity during repititive muscle contraction during oxygen deficti ?
    11·1 answer
  • You are configuring NIC teaming on a server with two network adapters. You chose Switch Independent Mode. You now must choose be
    15·1 answer
  • One way to check if a website is secure is to look for a/an<br> in the address bar.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!