Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
Using a for Loop
NewMultiply.java
1 // NewMultiply.java - This program prints the numbers 0 through 10 along
2 // with these values multiplied by 2 and by 10.
3 // Input: None.
4 |/ Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10.
Summary
In this lab the completed program should print the
5
numbers O through 10, along with their values multiplied
by 2 and by 10. You should accomplish this using a for
7 public class NewMultiply
8 {
loop instead of a counter-controlled while loop.
public static void main(String args[])
{
10
Instructions
11
12
String headl = "Number: ";
1. Write a for loop that uses the loop control variable
13
String head2 = "Multiplied by 2: ";
14
String head3 = "Multiplied by 10: ";
to take on the values 0 through 10.
// Numbers 0 through 10.
// Stores the number multiplied by 10.
// Stores the number multiplied by 2.
final int NUM_LOOPS = 10; // Constant used to control loop.
15
int numberCounter;
2. In the body of the loop, multiply the value of the loop
16
int byTen;
17
int byTwo;
control variable by 2 and by 10.
18
3. Execute the program. Is the output the same?
19
// This is the work done in the housekeeping() method
System.out.println("0 through 10 multiplied by 2 and by 10" + "\n");
20
21
Grading
22
// This is the work done in the detailLoop() method
// Write for loop
23
When you have completed your program, click the Submit
24
button to record your score.
25
26
// This is the work done in the endOf Job() method
System.exit(®);
} // End of main() method.
27
28
29
30 } // End of NewMultiply class.
31
expand button
Transcribed Image Text:Using a for Loop NewMultiply.java 1 // NewMultiply.java - This program prints the numbers 0 through 10 along 2 // with these values multiplied by 2 and by 10. 3 // Input: None. 4 |/ Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10. Summary In this lab the completed program should print the 5 numbers O through 10, along with their values multiplied by 2 and by 10. You should accomplish this using a for 7 public class NewMultiply 8 { loop instead of a counter-controlled while loop. public static void main(String args[]) { 10 Instructions 11 12 String headl = "Number: "; 1. Write a for loop that uses the loop control variable 13 String head2 = "Multiplied by 2: "; 14 String head3 = "Multiplied by 10: "; to take on the values 0 through 10. // Numbers 0 through 10. // Stores the number multiplied by 10. // Stores the number multiplied by 2. final int NUM_LOOPS = 10; // Constant used to control loop. 15 int numberCounter; 2. In the body of the loop, multiply the value of the loop 16 int byTen; 17 int byTwo; control variable by 2 and by 10. 18 3. Execute the program. Is the output the same? 19 // This is the work done in the housekeeping() method System.out.println("0 through 10 multiplied by 2 and by 10" + "\n"); 20 21 Grading 22 // This is the work done in the detailLoop() method // Write for loop 23 When you have completed your program, click the Submit 24 button to record your score. 25 26 // This is the work done in the endOf Job() method System.exit(®); } // End of main() method. 27 28 29 30 } // End of NewMultiply class. 31
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education