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 37 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
Thanks for the timely response, appreciate it


recede

  • Member
  • Posts: 315
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

Most women experience menopause in their 50s. However, in 1994, an Italian woman gave birth to a baby boy when she was 61 years old.

Did you know?

The cure for trichomoniasis is easy as long as the patient does not drink alcoholic beverages for 24 hours. Just a single dose of medication is needed to rid the body of the disease. However, without proper precautions, an individual may contract the disease repeatedly. In fact, most people develop trichomoniasis again within three months of their last treatment.

Did you know?

Not getting enough sleep can greatly weaken the immune system. Lack of sleep makes you more likely to catch a cold, or more difficult to fight off an infection.

Did you know?

The newest statin drug, rosuvastatin, has been called a superstatin because it appears to reduce LDL cholesterol to a greater degree than the other approved statin drugs.

Did you know?

Parkinson's disease is both chronic and progressive. This means that it persists over a long period of time and that its symptoms grow worse over time.

For a complete list of videos, visit our video library