Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zajęcia3;
- import java.util.Scanner;
- public class wyjatek_cw {
- public static void main(String[] args) throws NieLiczba {
- Scanner sc = new Scanner(System.in);
- System.out.println("Podaj liczbę: ");
- double input = 0;
- while(true) {
- try {
- input = sc.nextDouble();
- break;
- }
- catch(NieLiczba e) {
- System.out.println(e.getMessage());
- continue;
- }
- }
- }
- }
- class NieLiczba extends Exception{
- public NieLiczba() {
- System.out.println("Podaj liczbę!!!");;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement