Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package topic05_work02;
- import java.util.Scanner;
- public class Validity2 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String number;
- double x;
- Scanner input = new Scanner(System.in);
- System.out.println("Enter a positive value < 100: ");
- number = input.nextLine();
- x = Double.parseDouble(number);
- do {
- validity(x);
- if (validity(x) == false) {
- System.out.println("Invalid input!");
- System.out.println("Enter a positive value < 100: ");
- number = input.nextLine();
- x = Double.parseDouble(number);
- }
- else {
- System.out.println("Great job!");
- }
- }
- while (validity(x) == false);
- System.out.println("Great job!");
- }
- public static boolean validity(double n) {
- if (0 < n && n < 100) {
- return true;
- }
- else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement