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
Andreyy89
3 years ago
8

Write a Raptor program that will generate a random number between 1 and 100; do not display the randomly generated number. Let t

he user guess within 3 tries what the random number is. Display appropriate messages based on each try, for example, "1 remaining try" or "You guessed correctly!"
Computers and Technology
2 answers:
zepelin [54]3 years ago
8 0

Answer:

Explanation:

Let's do this in Python, we can first generate the random number from 1 to 100. Then compare that with the input number from the guesser.

from random import random

random_0_1 = random()

random_1_100 = 1 if round(100*random_0_1) < 1 else round(100*random_0_1)

for trial in range(3):

    guess = input('Guess the number: ')

    if guess == random_1_11:

         print('You guessed correctly!')

         break

    else:

         print(2 - trial + " remaining try")

tekilochka [14]3 years ago
4 0

Answer:

The answer to this question can be given as:

Program:

#include <stdio.h>  //include header file.

#include <stdlib.h> //include header file.

int main ()  //main method.

{

 int number,choice;  //define variable.

 number = rand() % 10 + 1; //use random function and take value in number variable

 for(int i=1;i<=3;i++)  //loop for 3 time input.  

 {

   printf ("\n Enter the Guess number between 1 to 10 :\n"); //message

   scanf ("%d",&choice); //input a number

   if (number<choice)  //check number

   {

   printf("Number is to lower\n try= %d",i); //message

   }

   else if (number>choice) //check number

   {

   printf("Number is to higher\n try= %d",i);   //message

   }

   else if(number==choice ||number!=choice)  //check number

   {

       printf("Congratulations...! \n You guessed correctly!\n");  //message

       break;

   }

 }

   printf("\n Number is :%d\n",number);  //value

 return 0;

 }

Output:

Enter the Guess number between 1 to 10 :

5

Number is to lower

try= 1

Enter the Guess number between 1 to 10 :

8

Number is to lower

try= 2

Enter the Guess number between 1 to 10 :

6

Number is to lower

try= 3

Number is: 4

Explanation:

The above C language program can be described as:

  • In this program firstly we include header files.  Then we define the main function in this function we define a variable that is number and choice. The number variable holds the value of the random number that is taken by the rand function.
  • Then we define the loop. This loop is used to provide input validation. This means the user input number only three times. In this loop, we take input by the user in the choice variable.  
  • Then we use the conditional statement. In this statement, we check the numbers. If the value match in 3 inputs so, it will print the message "Congratulations...! You guessed correctly!". Otherwise, we will print the random function value.
You might be interested in
7.1 Write statements that create the following arrays: A 100-element int array referenced by the variable employeeNumbers. final
maria [59]

Answer:

A. int [ ] numbers = new int[employeeNumbers];

B. double[ ] numbers = new double[payRates];

C. float[ ] miles = new float[14];

D. char[ ] letters = new char[1000];

7.2 Size of array cannot be negative

Size of array should be a positive integer and not decimal.

7.4 The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element in an array.

7.5 subscript to be out-of-bound means the specified integer is not within the range of the length of the array.

Explanation:

The question has answer given for some. I guess the explanation is what is needed.

A. The general format of creating an array is:

data type[] arrayRefVar=new datatype[size];

In this case, the datatype is int, arrayRefVar is numbers, size is employeeNumbers. The size was already initialised to 100 (employeeNumber).

B. A wrong datatype was used.

double[ ] numbers = new double[payRates];

would create an array of size 25 which is the payRates with types double.

C. The array was re-written using the general format of creating an array is:

data type[] arrayRefVar=new datatype[size];

D. The array was correctly defined.

7 0
4 years ago
What are some of the visual clues a defensive driver can use to spot a impaired driver
Margaret [11]

Excessively low or high speed.

Inconsistent speed.

Swerving side to side or crossing the center line.

Failing to obey traffic signs or signals.

Getting out of the car at 40+ mph.

5 0
4 years ago
Read 2 more answers
Why are medical coders using encoded software
EastWind [94]
To keep the medical records confidential otherwise, hackers would take advantage of them and sell them to the highest bidder 
3 0
3 years ago
Your manager has asked you to recommend which of two new types of digital camera to buy for your company's publications departme
Neporo4naja [7]

Answer:

Website

Explanation:

In the digital world that we are in right now, the best place to conduct your research is online. By click of a mouse, I will be able to go through an unlimited list of websites online, search for the best digital cameras out there, do a purchase, and have the cameras delivered at the comfort of my chair. There are tremendous resources online that will help me choose what is the best for the company.

3 0
3 years ago
When using the magnetic lasso tool , which setting blurs the area between the selection and the surrounding pixels?
andre [41]
Your answer is the "feather" setting :)
3 0
4 years ago
Other questions:
  • Which is a network of devices built around a person, typically within 10 meters of range?
    5·1 answer
  • Which question best addresses the issue of risk with a new job?
    7·2 answers
  • If you enjoy exploring,"what would happen if"types of questions and activities,a career in science or technology might be a good
    7·1 answer
  • ossless compression tools generally use either Huffman coding or Lempel-Ziv-Welch (LZW) coding. Discuss the advantages and disad
    8·1 answer
  • Which view is easiest and most recommended for changing the order of the slides? A. Slideshow View B. Slide Sorter View C. Readi
    5·2 answers
  • Which term describes the gallery that allows you to customize and format text as a graphic? Pull Quote Text Box WordArt Drop Cap
    13·2 answers
  • Where the heck is the leader board?
    5·1 answer
  • You have one IP address provided from your ISP with a /30 mask. However, you have 300 users that need to access the Internet. Wh
    10·1 answer
  • How to write a C++ program that lets the user guess if a randomly generated integer is even or odd then the computer lets them k
    6·1 answer
  • a network administrator for a large oil company has discovered that a host on the company network has been compromised by an att
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!