Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
medium Solved by 13 students

Java For Loop Code Tracing

Mark
< Prev
Next >

What is printed when the following code segment is executed?

double principal = 1000.0;
double rate = 0.05;
int years = 3;
double amount = principal;
for (int i = 0; i < years; i++) {
    amount = amount * (1 + rate);
}
System.out.println((int) amount);
A

1157

B

1200

C

1158

D

1150

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1mertdeg11 - 100
#2hitrishabhatia11 - 100
#3sgarv251312 - 90
#4midnightasdark11 1m 11s 29
#5171662811 1m 36s 4
#6suhanakochhar00611 2m 15s -35
#7busemagngr22 3m 55s -35
#8yuvansankarnyc11 2m 51s -71
#9barkern19501 1m 07s -77
#10gtsak3111 5m 01s -201
Items per page:
10
1 – 10 of 13
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|