Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In Slovak Language.
- import java.util.*;
- import java.io.* ;
- class start {
- static String again;
- static int div;
- public static BufferedReader reader;
- public static void main (String args[]) throws IOException {
- reader = new BufferedReader(new InputStreamReader(System.in));
- do {
- System.out.println("Vlozte (1) pre numericku kalkulacku, (2) pre euro kalkulacku:");
- String decision = reader.readLine();
- int decision2 = Integer.parseInt(decision);
- if(decision2 == 1) {
- System.out.println('\n' + "Vybrali ste si numericku kalkulacku.");
- System.out.println("Vloz prve cislo:");
- String num1 = reader.readLine();
- int n1 = Integer.parseInt(num1);
- System.out.println("Vyber si operaciu:");
- String op1 = reader.readLine();
- char op2 = op1.charAt(0);
- System.out.println("Vloz druhe cislo:");
- String num2 = reader.readLine();
- int n2 = Integer.parseInt(num2);
- try {
- if (op2 == '+') {
- int plus;
- plus = n1+n2;
- System.out.println('\n'+ "Sucet je: " + plus);
- }
- }
- catch(ArithmeticException v) {
- System.out.println("Chyba: " + v.getMessage());
- }
- try {
- if (op2 == '-') {
- int minus;
- minus = n1-n2;
- System.out.println('\n'+ "Rozdiel je: " + minus + ".");
- }
- }
- catch (ArithmeticException v) {
- System.out.println("Chyba: " + v);
- }
- try {
- if (op2 == '*') {
- int mult;
- mult = n1*n2;
- System.out.println('\n'+ "Sucin je: " + mult + ".");
- }
- }
- catch (ArithmeticException v) {
- System.out.println("Chyba: " + v);
- }
- try {
- if (op2 == '/' && n2 == 0)
- throw new ArithmeticException ("Delenie nulou.");
- if (op2 == '/' && n2 != 0) {
- div = n1/n2;
- System.out.println('\n'+ "Podiel je: " + div + ".");
- }
- }
- catch (ArithmeticException v) {
- System.out.println("Chyba: " + v.getMessage());
- }
- }
- if (decision2 == 2) {
- System.out.println('\n' + "Vybrali ste si euro kalkulacku.");
- System.out.println("Vlozte pocet eur: ");
- String euro = reader.readLine();
- int euro2 = Integer.parseInt(euro);
- try {
- if (euro2 == 0 || euro2 > 4)
- System.out.println(euro2 + " eur je priblizne " + euro2*30 + " korun.");
- if (euro2 == 1)
- System.out.println(euro2 + " euro je priblizne " + euro2*30 + " korun.");
- if (euro2 == 2 || euro2 == 3 || euro2 == 4)
- System.out.println(euro2 + " eura su priblizne " + euro2*30 + " korun.");
- }
- catch (ArithmeticException v) {
- System.out.println("Chyba: " + v);
- }
- }
- System.out.println('\n' + "Spustit znova? y/n");
- again = reader.readLine();
- }
- while(!again.equals("n"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment