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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:00, jcastronakaya
Apex q: what does a low employment rate indicate? a. not many people are earning high salaries b. not many people are going to college c. not many people are renting their homes d. not many people have jobs
Answers: 2
image
Computers and Technology, 22.06.2019 19:30, keke6361
When using a public computer or network, you should always
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, gabby640
Name the range function that would generate the following list of integers values: 0,1,2,3,4,5.
Answers: 1
image
Computers and Technology, 23.06.2019 16:10, alexis9658
What is the ooh? a. omaha occupation handbook b. online occupational c. occupations online d. occupational outlook handbook select the best answer from the choices provided
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 in other subjects:

Konu
Arts, 01.02.2022 14:00
Konu
Mathematics, 01.02.2022 14:00