Which statement below best outlines the choice (A or B) Kyle should - ProProfs Discuss
Topics
Products
Follow Us:

Which statement below best outlines the choice (A or B) Kyle should make concerning his code?



Kyle is working on a loop that will execute several lines of code multiple times within a program.  Each time the code executes the program should prompt the user to enter in a test grade.  He is debating between the following two program statement setups A. for (int index = 0; grade < index; index++) System.out.print (Please enter another grade); grade= keyboard.readDouble(); B. for (int index = 0; grade < index; index++) { System.out.print (Please enter another grade); grade= keyboard.readDouble(); }

A. The code within section A or B would allow the person to enter the grade multiple times
B. The code within section A would be the best selection because the {} brackets indicate a decision must be made within a program.
C. The for loop is structured incorrectly in both A and B meaning Kyle should rewrite the code statement.
D. The code within section B is the best selection because the {} brackets allow both lines of code to be executed each time the loop occurs.

This question is part of Computer Programming II Exam (Multiple Choice)
Asked by Justinsmith, Last updated: Mar 19, 2020

+ Answer
Request

1 Answer

justinsmith

Justinsmith

Answered Jan 16, 2018

The code within section B is the best selection because the {} brackets allow both lines of code to be executed each time the loop occurs.
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.