Provide a mechanism for repeating a block of code

Assignment Help JAVA Programming
Reference no: EM131444742

Lab Project: The while Loop

Lab 1

Loops provide a mechanism for repeating a block of code called the loop body. We begin this lab by experimenting with while loops, the simplest form of loop code. Many loops are controlled with a single variable, which we will refer to as the loop control variable or the loop index.

Consider the code below. What is the output the program produces? Try changing the assigned value (6) of the limit variable to various integer values (e.g., 10, 100, 0, -10). What happens?

/**
A simple program that prints a loop control variable.
*/
public class SimpleLoop
{
public static void main(String[] args)
{
inti = 0;
int limit = 6;
while (i< limit)
{
System.out.println("i = " + i);
i++;
}
}
}

Lab 2

Consider the code below again. What happens if you comment out the line that increments i (line 13)? Will the program ever stop looping?

/**
A simple program that prints a loop control variable.
*/
public class SimpleLoop
{
public static void main(String[] args)
{
inti = 0;
int limit = 6;
while (i< limit)
{
System.out.println("i = " + i);
i++; // line 13
}
}
}

Lab 3

Manipulating the loop control variable is a critical skill in learning to write code with loops. Modify the program in Lab 1 so that it produces the following output:

i = 6
i = 8
i = 10
i = 12
i = 14
i = 16
i = 18
...
i = 98

What Do I Hand In?

Once you are done, submit your answers for Lab 1 and Lab 2, and upload the completed source code file (i.e., .java file) for Lab 3.

Reference no: EM131444742

Questions Cloud

Creating forensic system case file for analyzing evidence : Creating a Forensic System Case File for Analyzing Forensic Evidence - Create a new digital forensic case file using a forensic application and Document a new digital forensic case with digital evidence submitted to the newly created case file.
What is the most common housing pricing strategy : REE 6147 - Spring 2017 Course Exam. According to Table 2, what is the most common housing pricing strategy employed in the market? What is the second most common pricing strategy
Presidential candidates are popular in area : Suppose you are designing and conducting a poll to see which of the presidential candidates are popular in your area.
Evaluate the organizations productivity : In the Middleboro Physician Care Services, Inc. case, you are asked to examine the operations of an ambulatory, non-emergent care clinic which treats private and occupational health patients and provides services which do not include continuing o..
Provide a mechanism for repeating a block of code : CPS 150- Loops provide a mechanism for repeating a block of code called the loop body. We begin this lab by experimenting with while loops, the simplest form of loop code.
What is the cointegrating coefficient : One version of the expectations theory of the term structure of interest rates holds that a long-term rate equals the average of the expected values of short-term interest rates into the future, plus a term premium that is 1(0).
What is the probability that a randomly selected dropout : According to a recent study,9.3 % of high school dropouts are 16- to 17-year-olds. In addition,6.5 % of high school dropouts are white16- to17-year-olds. What is the probability that a randomly selected dropout is white, given that he or she is 16..
Depreciation expense on the income statement : When you buy a vehicle for dollar 10,000 dollars, on the balance sheet you would reduce cash by dollar 10,000 and increase Property, Plant & Equipment by dollar 10,000.  What TWO adjustments would you need to make in your Balance Sheet to make it bal..
Compare to a population of candidate votes : This would be an example of two mean comparison. In terms of the recent election, Gallup may take a sample and compare to a population of candidate votes (sample mean compared to a population mean).

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd