Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class WhileLoopsPractice {
- public static void main(String[] args) {
- float a = Float.parseFloat(JOptionPane.showInputDialog("Type a number to get the sqrt (negative number to exit)"));
- while(a >= 0) {
- JOptionPane.showMessageDialog(null, Math.sqrt(a));
- a = Float.parseFloat(JOptionPane.showInputDialog("Type a number to get the sqrt (negative number to exit)"));
- }
- char b = (JOptionPane.showInputDialog("Enter a letter to check if its a vowel (# to exit)")).charAt(0);
- while(b != '#') {
- if(b=='a'||b=='e'|b=='i'||b=='o'||b=='u')
- JOptionPane.showMessageDialog(null,b+ " is a vowel");
- else
- JOptionPane.showMessageDialog(null,b+" is not a vowel");
- b = (JOptionPane.showInputDialog("Enter a letter to check if its a vowel (# to exit)")).charAt(0);
- }
- int c = Integer.parseInt(JOptionPane.showInputDialog("Enter a letter to check if its a vowel (# to exit)"));
- while(c <= 255 && c >=0) {
- JOptionPane.showMessageDialog(null,(int)c);
- c = Integer.parseInt(JOptionPane.showInputDialog("Enter a letter to check if its a vowel (# to exit)"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement