Iteration Loops

Iteration Loops

<p>Orange Coast College Business, Computing, & Career Education Division CS/CIS Department CS A170 (Java Programming ) Lab 11 Instructor: Martha Malaty CS 170 – Lab 11 Iteration – Loops</p><p>Introduction The purpose of this homework is to introduce you to the fundamental concepts of loops using the While, Do-While, and For statement</p><p>Notes  For all programs the header from the template should be used.  Attach a Word file including the “Pseudocode” of the algorithm, as well as screen shots for running the programs.  Add reasonable comments through all the program.  All lab and homework classes should be grouped in one project.  Make sure to follow the naming convention for the project name.</p><p>I. Stars  Use nested for loops to write a program named “Stars“ that asks for the number of stars to be displayed and then generates the output pattern of stars shown below: o Note that there are no spaces in between stars. Sample Output:</p><p>Page 1 of 3 Orange Coast College Business, Computing, & Career Education Division CS/CIS Department CS A170 (Java Programming ) Lab 11 Instructor: Martha Malaty</p><p>II. Tracing Note: You can add as many rows in the table as needed a) What is the output of the following code segment? 1.int x = 4, y = 5, z = y + 6; 2. while(((z - x) % 4) != 0) { 3. System.out.println(z + " "); 4. z += 7; } Line x y z Condition Output</p><p> b) What is the output of the following code segment? 1. int num = 31; 2. int sum = 2; </p><p>Page 2 of 3 Orange Coast College Business, Computing, & Career Education Division CS/CIS Department CS A170 (Java Programming ) Lab 11 Instructor: Martha Malaty 3. while ( num < 40 ) { 4. sum = (num % 3); 5. num += sum; 6. System.out.println(num + " " + sum + " "); }</p><p>Line num sum Condition Output</p><p> c) What is the output of the following code segment? </p><p>1. int num = 31; 2. int sum = 2; do { 3. sum = (num % 5); 4. num += sum; 5. System.out.println(num + " " + sum + " "); }6. while ( num <= 40);</p><p>Line num sum Condition Output</p><p>Page 3 of 3</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us