blackpab

Java Zestaw 7 - Zadanie 3v1

Apr 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication12;
  7.  
  8. import java.util.InputMismatchException;
  9. import java.util.Scanner;
  10.  
  11. /**
  12.  *
  13.  * @author student
  14.  */
  15. public class Kalkulator {
  16.    
  17.    
  18.     public static void main(String[] args) {        
  19.                
  20.         Scanner skaner = new Scanner(System.in);        
  21.        
  22.         System.out.println("-== Kalkulator ==-");        
  23.         System.out.println("Dzielenie");        
  24.        
  25.         System.out.print("Dzielna: ");        
  26.         double a = 0;
  27.         try {
  28.             a = skaner.nextDouble();
  29.         } catch(InputMismatchException ex) {
  30.             System.out.println("BLAD: Niepoprawne dane wejsciowe: " + ex);
  31.             return;
  32.             //ex.printStackTrace();
  33.         }    
  34.          
  35.         System.out.print("Dzielnik: ");
  36.         double b = 0;        
  37.         try {
  38.             b = skaner.nextDouble();
  39.         } catch(InputMismatchException ex) {
  40.             System.out.println("BLAD: Niepoprawne dane wejsciowe: " + ex);
  41.             return;
  42.         }
  43.        
  44.         double c = a/b;
  45.         System.out.println("Iloraz: " + c);        
  46.     }    
  47. }
Add Comment
Please, Sign In to add comment