import javax.swing.*;
public class DataValidationExample {
public static void main(String[] args) {
String inputStr;
double marks;
do{
inputStr = JOptionPane.showInputDialog(null,"Enter your marks");
marks = Double.parseDouble(inputStr);
// show error message if invalid data
if (marks < 0 || marks>100)
JOptionPane.showMessageDialog(null,
"Enter marks between 0 and 100");
} while (marks < 0 || marks>100); // end while
JOptionPane.showMessageDialog(null,
"You scored " + marks);
} //end main
} //end class
Showing posts with label Topic 04. Show all posts
Showing posts with label Topic 04. Show all posts
Friday, October 13, 2006
Tuesday, October 10, 2006
DemoLoop
public class DemoLoops {
public static void main(String[] args) {
int counter = 0;
while (counter<5){
System.out.println("Welcome");
counter++;
//end while
int counter2 = 0;
do{
System.out.println("Welcome2");
counter2++;
}while (counter2<5);> (int i=0;i<5;i++){ color="#33cc00">//end for i
} //end main
} //end class
public static void main(String[] args) {
int counter = 0;
while (counter<5){
System.out.println("Welcome");
counter++;
//end while
int counter2 = 0;
do{
System.out.println("Welcome2");
counter2++;
}while (counter2<5);> (int i=0;i<5;i++){ color="#33cc00">//end for i
} //end main
} //end class
Subscribe to:
Posts (Atom)