Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import com.sun.tools.javac.Main;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class lekcja{
  6. public static void main(String[] args) {
  7.  
  8. int metr_1;
  9. int gram_1;
  10. int godzina_1;
  11. char wybor;
  12.  
  13.  
  14. Scanner wej = new Scanner(System.in);
  15. System.out.println("1.Zamień metry na kilometry");
  16. System.out.println("2.Zamień gramy na kilogramy");
  17. System.out.println("3.Zamień godziny na minuty");
  18. System.out.println("4.Wyjście z programu");
  19. System.out.println("Wpisz 1,2,3 lub 4");
  20.  
  21. wybor = wej.next().charAt(0);
  22.  
  23.  
  24. switch (wybor) {
  25. case '1': {
  26. System.out.println("Podaj liczbę metrów");
  27. metr_1 = wej.nextInt();
  28. System.out.println(metr_1 / 1000 + " kilometrów i " + metr_1 % 1000 + " metrów");
  29. main(args);
  30.  
  31. }
  32.  
  33.  
  34. case '2': {
  35. System.out.println("Podaj liczbę gramów");
  36. gram_1 = wej.nextInt();
  37. System.out.println(gram_1 / 1000 + " kilogramów i " + gram_1 % 1000 + " gramów");
  38. main(args);
  39. }
  40.  
  41. case '3': {
  42. System.out.println("Podaj liczbę godzin");
  43. godzina_1 = wej.nextInt();
  44. System.out.println(godzina_1 * 60 + " minut");
  45. main(args);
  46. }
  47.  
  48. case '4': {
  49. System.out.println("Miłego dnia :)");
  50. break; }
  51. }
  52.  
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement