please answer these questions for me thanks 394 1 Chapter 6


please answer these questions for me. thanks

394 1 Chapter 6: Repesting Instructions a while loop. Did the logic change? If so, explain. int counter100; NziteLine (counter) counter- while (counter 0 22. Write a for loop to display every third number beginning with 10 and continuing through 100. z3 Write a sentinel-controlled while loop that allows any number of tem- peratures to be entered. The average temperature should be calculated and displayed. Write a state-controlled loop that adds all these randomly generated num- bers until a value larger than 60 is generated. When the loop stops, display the number of acceptable generated values and the sum of those values. Desk run or trace the following code segment, showing every value that goes into each variable. 25. for (340i -- writeLine (\"(0}\\t {1}\", i, j);

Solution

Here are the solutions for you:

21.
int counter = 100;
do
{
writeLine(counter);
counter--;
}while(counter > 0);

for(int counter = 100; counter > 0; counter--)
writeLine(counter);

int counter = 100;
while(counter > 0)
{
writeLine(counter);
counter--;
}


22.
for(int i = 10; i <= 100; i += 3)
writeLine(i);

23.
writeLine(\"Enter the temperatures, 0 to stop: \");
total = 0.0;
count = 0;
temperature = 1;
while(temperature != 0)
{
temperature = readLine();
total += temperature;
count++;
}
average = total / count;

 please answer these questions for me. thanks 394 1 Chapter 6: Repesting Instructions a while loop. Did the logic change? If so, explain. int counter100; NziteL

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site