Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

using a counter controlled while loop

$
0
0
I can not figure out how to get the program to print numbers 1 through 10 as well as their values multiplied by 10 and 100, when I run the program the values print but not the numbers 1 through ten.


// Multiply.java - This program prints the numbers 0 through 10 along
// with these values multiplied by 10 and by 100.
// Input: None.
// Output: Prints the numbers 0 through 10 along with their values multiplied by 10 and by 100.


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

String head1 = "Number: ";
String head2 = "Multiplied by 10: ";
String head3 = "Multiplied by 100: ";
int numberCounter = 0; // Numbers 0 through 10.
int byTen = numberCounter * 10; // Stores the number multiplied by 10.
int byHundred = numberCounter * 100; // Stores the number multiplied by 100.
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 10 and by 100" + "\n");

// This is the work done in the detailLoop() method
// Initialize loop control variable.
int count = 0;
// Write your counter controlled while loop here
while (count <= 10)
{
System.out.println(count * 10);// Multiply by 10
count++;
System.out.println(count * 100);// Multiply by 100
}
System.out.println(head1 + numberCounter);
System.out.println(head2 + byTen);
System.out.println(head3 + byHundred);
// Next number.
// This is the work done in the endOfJob() method
System.exit(0);
} // End of main() method.

} // End of Multiply class.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>