This topic contains a solution. Click here to go to the answer

Author Question: Which of the following loops correctly computes 1/2 + 2/3 + 3/4 + ... + 99/100?A:double sum = 0;for ... (Read 42 times)

Kthamas

  • Hero Member
  • *****
  • Posts: 546

Question 1

Which of the following loops prints "Welcome to Java" 10 times?

A:
for (int count = 1; count <= 10; count++) {
System.out.println("Welcome to Java");
}

B:
for (int count = 0; count < 10; count++) {
System.out.println("Welcome to Java");
}

C:
for (int count = 1; count < 10; count++) {
System.out.println("Welcome to Java");
}

D:
for (int count = 0; count <= 10; count++) {
System.out.println("Welcome to Java");
}

◦ BC
◦ AC
◦ BD
◦ ABC
◦ AB

Question 2

Which of the following loops correctly computes 1/2 + 2/3 + 3/4 + ... + 99/100?

A:
double sum = 0;
for (int i = 1; i <= 99; i++) {
sum = i / (i + 1);
}
System.out.println("Sum is " + sum);

B:
double sum = 0;
for (int i = 1; i < 99; i++) {
sum += i / (i + 1);
}
System.out.println("Sum is " + sum);

C:
double sum = 0;
for (int i = 1; i <= 99; i++) {
sum += 1.0 * i / (i + 1);
}
System.out.println("Sum is " + sum);

D:
double sum = 0;
for (int i = 1; i <= 99; i++) {
sum += i / (i + 1.0);
}
System.out.println("Sum is " + sum);

E:
double sum = 0;
for (int i = 1; i < 99; i++) {
sum += i / (i + 1.0);
}
System.out.println("Sum is " + sum);

◦ CD
◦ BCD
◦ B
◦ CDE
◦ ABCD


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by Kthamas on May 6, 2020

jessicaduplan

  • Sr. Member
  • ****
  • Posts: 337
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 39% of students answer this correctly




Kthamas

  • Member
  • Posts: 546
Reply 2 on: May 6, 2020
:D TYSM


Jossy

  • Member
  • Posts: 336
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

About 3% of all pregnant women will give birth to twins, which is an increase in rate of nearly 60% since the early 1980s.

Did you know?

Addicts to opiates often avoid treatment because they are afraid of withdrawal. Though unpleasant, with proper management, withdrawal is rarely fatal and passes relatively quickly.

Did you know?

People with alcoholism are at a much greater risk of malnutrition than are other people and usually exhibit low levels of most vitamins (especially folic acid). This is because alcohol often takes the place of 50% of their daily intake of calories, with little nutritional value contained in it.

Did you know?

In ancient Rome, many of the richer people in the population had lead-induced gout. The reason for this is unclear. Lead poisoning has also been linked to madness.

Did you know?

The ratio of hydrogen atoms to oxygen in water (H2O) is 2:1.

For a complete list of videos, visit our video library