| 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
< 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

1150

C

1158

D

1200

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1hitrishabhatia11 0m 00s 100
#2mertdeg11 0m 00s 100
#3sgarv251312 0m 00s 90
#4midnightasdark11 1m 11s 29
#5suhanakochhar00611 2m 15s -35
#6gtsak3111 5m 01s -201
#7y.seong202702 4m 07s -267
#8kazvin.tjakradinata14 6m 19s -309
#9Pelisx11 30m 48s -1,748
Items per page:
10
1 – 9 of 9
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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