Guest User

Untitled

a guest
Jun 26th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. public class Main {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. int k=1;
  6. do{
  7. System.out.println("Podaj 2 liczby");
  8. Scanner odczyt=new Scanner(System.in);
  9. double a=odczyt.nextDouble();
  10. double b=odczyt.nextDouble();
  11. System.out.println("Wcisnij + jesli chcesz dodac");
  12. System.out.println("Wcisnij - jesli chcesz odjąć");
  13. System.out.println("Wcisnij * jesli chcesz pomnozyc");
  14. System.out.println("Wcisnij / jesli chcesz podzielic");
  15. Scanner odczyt2=new Scanner(System.in);
  16. String znak=odczyt2.nextLine();
  17. switch (znak){
  18. case "+":
  19. System.out.println("Wynik dodawania to "+(a+b));
  20. break;
  21. case "-":
  22. System.out.println("Wynik odejmowania to "+(a-b));
  23. break;
  24. case "":
  25. System.out.println("Wynik mnozenia to "+(a*b));
  26. break;
  27. case "/":
  28. System.out.println("Wynik dzielenia to "+(a/b));
  29. break;
  30. default:
  31. System.out.println("Zle wybrales");
  32. }
  33. System.out.println("Czy chcesz wykonac program jeszcze raz? jesli tak wcisnij jeden ");
  34. k=odczyt2.nextInt();
  35. }
  36. while (k==1);
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment