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
cupoosta [38]
3 years ago
7

Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correc

t answer. But when Adam tests the program, it always outputs that it took the user one guess, even when it takes many guesses. What error did Adam most likely make, and how should it be fixed?
Computers and Technology
1 answer:
Tpy6a [65]3 years ago
6 0

Answer:

This is the game guess the number. The computer ask you. Hey! I have thought of a number in between 1 and 20. Can you guess what the number is? If you predict correct, Computer says you guessed right and in so and so number of times. Or else if your guess is larger than guess than it says your guess is too high and it says too low if guessed number is less than the guess. However, in this program it always says it guessed right in one attempt. Actually, we use here if else ladder, The problem is in this if else ladder expression. It has not been set properly. Hence, Adam needs to check that part of the program.

if guessd_number == guess:

            attempt++

            print( "you guessed right in" +attempt+"attempts)

elif guessed_number < guess:

            attempt++

            print("your guess is too low")

else:

            attempt++

            print("your guess is too high")

And this will be inside a while loop. The problem is definitely here.

Explanation:

The answer is self explanatory.

You might be interested in
Consider the following code segment. How many unique new (do not count the starting process) processes are created? (you may wan
valkas [14]

The number of unique processes that are created is in the original process, you get the PID of the child process. In the child process, you get 0.

<h3>What is a Code Segment?</h3>

This refers to the portion of an object file that is in the virtual space of a computer that contains executable instructions.

Hence, we can note that since PID >= 0, then there would be the creation of two identical processes in which the original process returns the PID of the child process, and the output in the child process would be zero.

If we make use of a canonical tag,

p = fork();\\if (0 == p)

{

   // We're the child process

}

else if (p > 0)

{

   // We're the parent process

}

else

{

   // We're the parent process, but the child couldn't be created

}

Read more about code segments here:

brainly.com/question/25781514

#SPJ1

3 0
3 years ago
You need to write th java syntax for the expression “7 is greater than or equal to 3” choose the best answer
shtirl [24]
If(7>=3)
{
.
.
.
}
Mark as brainliest
8 0
4 years ago
Suppose that the first goal in a GP problem is to make 3 X1 + 4 X2 approximately equal to 36. Using the deviational variables d1
Scrat [10]

Answer:

d. d1− = 10, d1+ = 0

Explanation:

Given

3X1 + 4X2 +d1− − d1+ = 36

X1 = 6

X2 = 2

Required

Possible values of d1- and d1+

We have:

3X1 + 4X2 +d1− − d1+ = 36

Substitute values for X1 and X2

3 *6 + 4 * 2 + d1- - d1+ = 36

18 + 8 + d1- - d1+ = 36

Collect like terms

d1- - d1+ = 36 - 18 - 8

d1- - d1+ = 10

For the above equation to be true, the following inequality must be true

d1- > d1+

Hence,

(d) is correct

Because:

10 > 0

3 0
3 years ago
Why we need each section of prologprogram?
evablogger [386]

Answer:

Prolog program are used in the artificial intelligence and the web development in a systematic manner process. As, it is also sometimes known as declarative language which basically consist of some facts and list. Prolog program are divided into the sections that are:

  • Domain sections
  • Clauses sections
  • Predicates sections
  • Goal sections

We need each section of the prolog program because all the sections introduced the systematic program and performed there particular functions so by using all these processing steps an efficient function are formed.

6 0
3 years ago
Write a Java program that accepts an integer number from the user between 20 and 100. Next, divide the number by 12 and determin
Eddi Din [679]
Import java.util.Scanner;
class hola
{
public static void main(String[]args)
{
Scanner x=new Scanner(System.in);
int a=x.nextInt();
int b;
if(a>20&&a<100)
{
b=a%12;
if(b%2==0){
System.out.print("es par"+b);
}
else{
System.out.print("es impar"+b);
}
}
}

}
4 0
4 years ago
Other questions:
  • To create a formula in ____, you would first click in one of the cells.
    15·2 answers
  • What is used for World Wide Web?
    7·1 answer
  • How do you get the value of an element in an array? And how about for an ArrayList?
    14·1 answer
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • I need help with getting a profile pic
    5·1 answer
  • A global project called One Laptop per Child is attempting to distribute low-cost laptop computers to children in developing cou
    10·1 answer
  • What to do when you accidentally delete usb drivers?
    8·1 answer
  • Who invented slide Rule and when?​
    7·2 answers
  • Choose the correct color to complete the sentence.
    15·1 answer
  • Fiscal policy includes each of the following except? 1) the money supply. 2) taxes. 3) government spending. 4) the automatic sta
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!