vendredi 15 juin 2018

catch statement dosent work in do/while loop

Look at thees codes and tell why the catch statement dosent work. please explain and write the right codes.tnx.

import java.util.InputMismatchException;
import java.util.Scanner;

public class WhileLoop {

public static void main(String[] args) {


    System.out.println("Enter a number bigger than 50 please: ");
    Scanner input=new Scanner(System.in);
    int numInput=input.nextInt();

    do{
        try{
            if(numInput<=50){
                System.out.println("Sorry,you dident entered a number bigger than 50.");
            }else{
                System.out.println("***You Rock***");
            }

        }catch(InputMismatchException e){
            System.out.println("Please enter a number");
        }
        break;
    }while(numInput<=50);
    }

    }

Aucun commentaire:

Enregistrer un commentaire