subject

In this lab, you use a counter-controlled While loop in a Java program provided with the data files for this book. When completed, the program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. The Data file contains the necessary variable declarations and output statements.
1. Open the source code file named Multiply. java using Notepad or the text editor of your choice.
2. Write a counter-controlled While loop that uses the loop control variable to take on the values 0 through 10. Remember to initialize the loop control variable before the program enters the loop.
3. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Remember to change the value of the loop control variable in the body of the loop.
4. Save the source code file in a directory of your choice, and then make that directory your working directory.
5. Compile the source code file Multiply. java.
6. Execute the program. Record the output of this program.

Multiply. java file

//Lab 5-1: Using a Counter-Controlled while Loop
// Multiply. java - This program prints the numbers 0 through 10 along
// with these values multiplied by 2 and by 10.
// Input: None.
// Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10.

public class Multiply
{
public static void main(String args[])
{

String head1 = "Number: ";
String head2 = "Multiplied by 2: ";
String head3 = "Multiplied by 10: ";
int numberCounter; // Numbers 0 through 10.
int byTen; // Stores the number multiplied by 10.
int byTwo; // Stores the number multiplied by 2.
final int NUM_LOOPS = 10; // Constant used to control loop.

// This is the work done in the housekeeping() method
System. out. println("0 through 10 multiplied by 2 and by 10" + "\n");

// This is the work done in the detailLoop() method
// Initialize loop control variable.
numberCounter = 0;
// Write your counter controlled while loop here

// This is the work done in the endOfJob() method
System. exit(0);
} // End of main() method.

} // End of Multiply class.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 12:00
Which of the following “invisible” marks represents an inserted tab?
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
What are procedures that keep a data base current
Answers: 1
question
Computers and Technology, 23.06.2019 06:00
Which statement is true of web-based social media? a.they allow consumers to interact with and update content. b.they cannot be updated easily, as compared to print media. c.they are expensive to produce and maintain, as compared to print and television. d.they can exist independent of the internet.
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
What is the primary difference between the header section of a document and the body? a. the body is displayed on the webpage and the header is not. b. the header is displayed on the webpage and the body is not. c. the tag for the body is self-closing, but the tags for the headers must be closed. d. the tag for the header is self closing, but the tag for the body must be closed.
Answers: 3
You know the right answer?
In this lab, you use a counter-controlled While loop in a Java program provided with the data files...
Questions
question
Mathematics, 02.07.2019 23:00