Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
medium Solved by 10 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
#1hitrishabhatia11 0m 00s 100
#2mertdeg11 0m 00s 100
#3sgarv251312 0m 00s 90
#4midnightasdark11 1m 11s 29
#5suhanakochhar00611 2m 15s -35
#6busemagngr11 2m 24s -44
#7yuvansankarnyc11 2m 51s -71
#8gtsak3111 5m 01s -201
#9y.seong202702 4m 07s -267
#10kazvin.tjakradinata14 6m 19s -309
Items per page:
10
1 – 10 of 11

AI Tutor

How can I help?

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