Tara D
2008-09-26 18:51:48 UTC
using a WHILE LOOP:
prompt user for two integers, output odd numbers between
the two integers, output the even numbers between the two
integers using a while loop
using a FOR LOOP:
output all numbers and their squares between 1 and 10
using a DO WHILE LOOP:
output all the uppercase letters
this is what i have so far and i have never ending loops how can i end them so they are never ending. I am still in basic java here and learning. Thank you for any help! :-D
//******************************************************
// Tara D
// CS1 -- 10:00 -- Pgm #5
//
// Program Convert: create a while loop, for loop, and a
// do while loop
//******************************************************
/*
prompt user for two integers, output odd numbers between
the two integers, output the even numbers between the two
integers using a while loop, then using a for loop to output
all numbers and their squares between 1 and 10, and a do
while loop to output all the uppercase letters
*/
//******************************************************
import java.util.*;
import java.io.*;
import javax.swing.JOptionPane;
public class looping
{
static Scanner console = new Scanner( System.in);
public static void main(String[] args)
{
int firstNum;
int secondNum;
int oddNums = 0;
int evenNumbs = 0;
int number;
firstNum = Integer.parseInt(JOptionPane.showInputDialog("Enter an integer: "));
secondNum = Integer.parseInt(JOptionPane.showInputDialog("Enter an integer larger than first number: "));
while (firstNum > secondNum)
System.out.println("First number can't be larger than second number, try again.");
for (number = firstNum + 1; number < secondNum; number++)
{
while (number%2 == 0/2)
System.out.println(number);
while (number%2 != 0/2);
System.out.println(number);
}
}
}