For this assignment, you will be analyzing the Java™ code in the linked Week 3 Analyze Assignment Zip File, and predicting the results. You will also examine both the code and the output for inconsistencies and clarity. This Java™ code includes examples of for, while, and do-while loops.

/************************************************************************************** * Program: PRG/420 Week 3 * Purpose: Week 3 Analyze Assignment * Programmer: Iam A. Student * Class: PRG/420 * Creation Date: 10/22/17 ****************************************************************************************** * Program Summary: For, while, and do-while loops * * This program demonstrates the syntax for the for, while, and do-while loops. It also * contains comments that explain why a programmer would use a for loop over a while or do-while * loop. * * Notice the increment operator (i++) and also notice the copious use of println() statements. * Using System.out.println() is an excellent way to debug your code–especially if your loop code * is giving unexpected results. *****************************************************************************************/ package PRG420Week3_AnalyzeAssignment; public class PRG420Week3_AnalyzeAssignment { public static void main(String[] args) { // for loops are a good choice when you have a specific number of values // you want to iterate over and apply some calculation to. System.out.println(“FOR LOOP – Here are the taxes on all 10 prices:”); double taxRate = 0.08; for (int price=1; price

Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document:

  1. What is the output of the program as it is written?
  2. What improvement(s) could be made to this code to make the output clearer or more accurate, or to make the code easier to maintain?

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *