Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner;
  3.  
  4. public class Interfejs {
  5.  
  6. public Interfejs() {
  7. Scanner odczyt = new Scanner(System.in);
  8. Scanner menu = new Scanner(System.in);
  9. String kod, kod2;
  10. double ilosc;
  11. boolean bool =true;
  12. while (bool) {
  13. System.out.println();
  14. System.out.println("Program do przeliczania walut");
  15. System.out.println("--------------------------------");
  16. System.out.println("MENU:");
  17. System.out.println();
  18. System.out.println("1) Pokaż wszystkie kody walut i ich kursy.");
  19. System.out.println("2) Przelicz konkretną walutę.");
  20. System.out.println("3) Zdobądź kurs waluty po kodzie");
  21. System.out.println("4) Zamknij program");
  22.  
  23. try {
  24. int odpowiedz = menu.nextInt();
  25.  
  26. switch (odpowiedz) {
  27. case 1:
  28. CurrencyRepository.getAllCurency();
  29. bool = ControlInterface.CheckingInterface();
  30. break;
  31. case 2:
  32. do {
  33. System.out.println("Podaj kod waluty jaka posiadasz:");
  34. kod = odczyt.nextLine();
  35. }
  36. while (Check.checkkod(kod));
  37. while (true) {
  38. try {
  39. System.out.println("Podaj ilosc waluty jaka posiadasz:");
  40. Scanner odczyt1 = new Scanner(System.in);
  41. ilosc = odczyt1.nextDouble();
  42. break;
  43.  
  44. } catch (InputMismatchException e) {
  45. System.out.println("Nie podales liczby");
  46. }
  47. }
  48. do {
  49. System.out.println("Podaj na jaka chcesz wymienic:");
  50. kod2 = odczyt.nextLine();
  51. }
  52. while (Check.checkkod(kod2));
  53.  
  54. Calculator cal = new Calculator(kod, ilosc, kod2);
  55. bool=ControlInterface.CheckingInterface();
  56. break;
  57. case 3:
  58. Scanner wpisz = new Scanner(System.in);
  59. System.out.println("Wpisz kod waluty:");
  60. String kodWaluty = wpisz.nextLine();
  61. CurrencyRepository.getCurrencyByCode(kodWaluty);
  62. bool=ControlInterface.CheckingInterface();
  63.  
  64. break;
  65. case 4:
  66. System.exit(0);
  67. break;
  68. }
  69. } catch (Exception e) {
  70. System.out.println("Nie podales odpowiedniej cyfry. Program zakonczy swoje dzialanie!");
  71. }
  72.  
  73.  
  74. }
  75.  
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement