Let's get started with a program that uses a while loop!
Open Eclipse
Right-Click on your buffalo.edu.fa23. package
Choose: File -> New -> class
In the Name: textbox type: Thirteens
Click: Finish
Copy the Thirteens.java Template (Java) code (below)
Paste that code into your new Thirteens class in the editor
Change both occurrences of put-your-lastname-here
Replace blank on these lines: int[] thirteens = new int[__];
while (numFound < __) {
System.out.println("First __ multiples of 13:");
for (int i = 0; i < __; i++) {
line with an integer between 5 and 20
What would be a better way to declare the array size?
Click the Run icon
Thirteens.java Template (Java)
package buffalo.edu.fa23.put-your-lastname-here;
/**
*
* File: Thirteens.java
*
* Create a Java class named Thirteens that prints out a 13s multiplication table.
*
* 1) This class contains a main( ) method which creates an
* array to hold the multiples of 13 then walks through
* that array and prints the results
*
/**
*
* @authorput-your-name-here
*
*/public class Thirteens {
public static void main( String args[] ) {
int[] thirteens = new int[__]; // declare an array to hold multiples of 13intnumFound = 0;
// candidate: the number that might be a multiple of 13intcandidate = 1;
// build array that holds multiples of 13while (numFound < __) {
if (candidate % 13 == 0) {
thirteens[numFound] = candidate;
numFound++;
}
candidate++;
}
System.out.println("First __ multiples of 13:");
// walk through array that holds multiples of 13for (inti = 0; i < __; i++) {
System.out.println("13 * " + (i + 1) + " = " + thirteens[i]);
}
}
}