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
faust18 [17]
4 years ago
14

How many times does the following loop execute? double d; Random generator = new Random(); double x = generator.nextDouble() * 1

00; do { d = Math.sqrt(x) * Math.sqrt(x) - x; System.out.println(d); x = generator.nextDouble() * 10001; } while (d != 0); exactly once exactly twice can't be determined always infinite loop
Computers and Technology
1 answer:
iren [92.7K]4 years ago
5 0

Answer:

The number of execution can't always be determines

Explanation:

The following points should be noted

Variable d relies on variable x (both of double data type) for its value

d is calculated as

d = \sqrt{x}^2 - x

Mere looking at the above expression, the value of d should be 0;

However, it doesn't work that way.

The variable x can assume two categories of values

  1. Small Floating Point Values
  2. Large Floating Point Values

<em>The range of the above values depend on the system running  the application;</em>

<em></em>

When variable x assumes a small value,

d = \sqrt{x}^2 - x will definitely result in 0 and the loop will terminate immediately because \sqrt{x}^2 = x

When variable x assumes a large value,

d = \sqrt{x}^2 - x will not result in 0  because their will be \sqrt{x}^2 \neq  x

The reason for this that, the compiler will approximate the value of \sqrt{x}^2 and this approximation will not be equal to x

Hence, the loop will be executed again.

<em>Since, the range of values variable x can assume can not be predetermined, then we can conclude that the number of times the loop will be executed can't be determined.</em>

You might be interested in
16. Your character qualities never change. (3 points)<br> A. True<br> B. False
madam [21]

Answer:

False

Explanation:

Hope this helps!

3 0
3 years ago
Read 2 more answers
Which of these network connections would allow your smartphone to sync your photos to your online account? Choose all that apply
Anika [276]

Answer:

A & D

Explanation:

Wifi or IEEE 802.11a/n/g  is a wireless network medium used for communication between devices in a network (or the internet). It is used to transfer video, text, graphic, audio and all other types of files.

Cellular is a mobile networking technology used to make wireless communication over a large area of land called cell, between devices in a network or a remote network.

Both cellular and wifi connections are used to synchronize smartphones to online accounts and allows for data backup and retrieval.

5 0
3 years ago
When you are using remote control services and need to enter the ip address of the system you want to control, you should use th
il63 [147K]
<span>When you are using remote control services and need to enter the IP address of the system you want to control, you should use the ipconfig command.
</span>The name of the command ipconfig comes from internet protocol configuration. the command ipconfig displays the IP address, subnet mask, and default gateway for all interfaces. Besides that it d<span>isplays the network configuration, it can be used with parameters and can refresh DHCP and DNS settings.</span>
8 0
3 years ago
Write a class that specify the characteristics of a car, like type (sedan, jeep, mini, SUV, etc), gear (auto, manual), maximum s
iVinArrow [24]

Answer:

Answered below

Explanation:

This is written in Kotlin programming language.

//Creating the class Car. The primary //constructor declares car's properties which //are initialized when it's objects are created.

class Car(

val type: String,

val gear: String,

val maxSpeed: Double,

val avgFuelConsumption: Double)

//Creating several objects of car.

val sedan: Car = Car("sedan", "auto", 23.4, 500)

val jeep: Car = Car("jeep", "manual", 40, 350)

val mini: Car = Car("mini", auto, 26.7, 86, 234)

8 0
3 years ago
Terrence smiles at his customers, helps his cowokers,and stays late when needed. What personal skill does Terrence demonstrate
adell [148]

Answer: Humility,kindness

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • In today's society, unethical actions are: A) Easier than ever to get away with, because the general public and insurers are les
    13·2 answers
  • You discover memory is corrupted, what would be an indication of a software vs. a hardware issue?
    5·1 answer
  • What are tags?
    13·1 answer
  • Why is it important to evaluate the website on which you plan to shop?
    11·2 answers
  • As the team leader, John ensures that all his teammates are clear in the team goals they need to achieve. He demonstrates the qu
    12·2 answers
  • Ted reads a sentence: The man said that it would take 10 to 12 days for a reply. He believes the hyphen symbol can replace the w
    11·1 answer
  • Modify the definition of the throttle class on page 35, to create a new throttle ADT, which allows the user of the ADT to specif
    6·1 answer
  • When executing System.out.println(a2), the toString() method in the Object class is invoked. The program cannot be compiled, bec
    11·1 answer
  • Create a simple self-checkout system. Prompt for the prices and quantities of three items. Calculate the subtotal of the items.
    15·1 answer
  • Disk drives have been getting larger. Their capacity is now often given in terabytes (TB) where 1 TBequals1000 gigabytes, or abo
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!