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
Literally no one helps answer my questions so this website is pointless.... : /
Sergio039 [100]
I’ll help you, if I know the answer
3 0
3 years ago
Write a program in java that reads each line in a file, reverses its characters, and writes the resulting line to another file
Mandarinka [93]
Debugging program I think
4 0
3 years ago
Among the following, which is the best protection against ransomware?
goldfiish [28.3K]

Answer:

A

Explanation:

windows file history

7 0
3 years ago
Write a Java program that creates a two-dimensional array of type integer of size x by y (x and y must be entered by the user).
Law Incorporation [45]

Answer:

The java program is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 Random r = new Random();

 int x, y;

 x = input.nextInt();  

 y = input.nextInt();

 int[][] Array2D = new int[x][y];

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

     for(int j = 0; j < y; j++){          Array2D[i][j] = r.nextInt(9) + 1;      }

 }

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

     for(int j = 0; j < y; j++){          System.out.print(Array2D[i][j]+" ");      }

     System.out.println();

 }

 

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

     for(int j = 1; j < y; j+=2){          System.out.print(Array2D[i][j]+" ");      }

     System.out.println();

 }

}

}

Explanation:

This creates a random object

 Random r = new Random();

This declares x and y as integers

 int x, y;

This gets input for x

 x = input.nextInt();  

This gets input for y

 y = input.nextInt();

This declares the 2D array

 int[][] Array2D = new int[x][y];

The following iteration populates the array with integers 1 to 9

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 0; j < y; j++){          Array2D[i][j] = r.nextInt(9) + 1;      }</em>

<em>  }</em>

The following iteration prints all elements of the array

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 0; j < y; j++){          System.out.print(Array2D[i][j]+" ");      }</em>

<em>      System.out.println();</em>

<em>  }</em>

The following iteration prints all elements on the even column

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 1; j < y; j+=2){          System.out.print(Array2D[i][j]+" ");      }</em>

<em>      System.out.println();</em>

<em>  }</em>

<em />

3 0
2 years ago
1. Which of the following is not true about high-level programming language s? (a) Easy to read and write (b) Popular among prog
vazorg [7]

Answer:

1: c

2: c

Explanation:

The higher-level the language, the more it resembles human language.

In Python, the print() statement outputs text.

6 0
3 years ago
Other questions:
  • Which of these computers was marketed as a computer/game machine?
    15·2 answers
  • Describe how antipoverty programs can discourage the poor from working. How might you reduce this disincentive? What are the dis
    11·1 answer
  • You specify the shape of an oval in a Java applet by defining the oval's:__________.
    5·1 answer
  • Help what is a computer made from (computer class question)!!
    9·1 answer
  • Your program will search for prime numbers. You will first ask the user for the range of values to search, and use for loops to
    6·1 answer
  • He flow of electric charges through a material describes an electric _______.
    10·1 answer
  • Which similar computer network components connect multiple devices?
    7·1 answer
  • A thesaurus is an example of a(n)
    5·2 answers
  • HW2.24. Statement: Area of a Triangle The area of a triangle can be computed by knowing the base and height of the triangle usin
    11·1 answer
  • STM-1 contains 63 primary 2-Mbps data streams and each of them contains 30 time slots for speech.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!