Answers for "Loop Structure in Java"

0

Loop Structure in Java

numbers = new int[10];
numbersResult = "The resulting numbers inside Do While loop are:\n";
count = 0;
while (count < 10) {
	numbers[count] = (int) (count*8.87);
	numbersResult += "number " + String.valueOf(numbers[count] + "\n");
	count ++;
}
JOptionPane.showMessageDialog(null, numbersResult);
Posted by: Guest on April-22-2021
0

Loop Structure in Java

package tophCoding;

import javax.swing.JOptionPane;

public class DoWhileDiscussion {

	public static void main(String[] args) {
	
	String myString = ("This is my string.");
	String secondString = ("This is my second string.");
	String thirdString = ("This is my third string.");
    int x = (9);
    int y = (5);
    int z = (1);
    
    
        while (y <6) {
        	
            JOptionPane.showMessageDialog(null, secondString);
            y++;       
        }
        
        
        do {
        	JOptionPane.showMessageDialog(null, secondString);
        	y++;
        }
        while (y < 6);
 
        
        for(int y1 = 5; y1<6; y1= y1+1) {
        	JOptionPane.showMessageDialog(null, secondString);
        }
        
        
        
        
        
        
        
		do {
		    JOptionPane.showMessageDialog(null, myString);
		    x++;	
		}
		while (x < 10);
	    
		
		while (x<11) {
		    x++;
	        JOptionPane.showMessageDialog(null, myString);
	        }
		
		
		for (int x1 = 9; x1<10; x1= x1+1) {
			JOptionPane.showMessageDialog(null, myString);
		}
		
	
		
		
		
		
		
		
		for (int z1 = 1; z1<2; z1 = z+1) {
			JOptionPane.showMessageDialog(null, thirdString);
		}
		
		do {
			JOptionPane.showMessageDialog(null, thirdString);
		    z++;
		}
		while (z<2);
		
		while (z<3) {
			JOptionPane.showMessageDialog(null, thirdString);
			z++;
		}
		
		
	}
}
Posted by: Guest on April-22-2021

Browse Popular Code Answers by Language