ArthurC

Untitled

Nov 14th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. package ui;
  2.  
  3. import java.util.Calendar;
  4. import java.util.GregorianCalendar;
  5. import java.util.Scanner;
  6.  
  7. public class MenuApplicatie {
  8.  
  9. public static void main(String[] args) {
  10. String test;
  11. int keuze = toonMenuEnGeefKeuze();
  12. Scanner s = new Scanner(System.in);
  13. switch(keuze){
  14. case 1: test = geefBegroeting();
  15. break;
  16. case 2: test = toonHuidigeDatum();
  17. break;
  18. case 3: System.out.printf("Geef getal");
  19. int getal = s.nextInt();
  20. test = zetOmNaarHexadecimaal(getal);
  21. break;
  22. default: test = "";
  23.  
  24. }
  25. toonResultaat(test);
  26. }
  27.  
  28.  
  29. public static int toonMenuEnGeefKeuze() {
  30. Scanner s = new Scanner(System.in);
  31. int invoer;
  32.  
  33. do {
  34. System.out.printf("Menu: %n 1) Begroeting %n 2) Huidige datum %n 3) Naar Hexadecimaal %n 0) Stoppen %n Geef uw keuze%n");
  35. invoer = s.nextInt();
  36. } while (invoer>3||!(invoer>0));
  37. return invoer;
  38.  
  39.  
  40. }
  41.  
  42. public static String geefBegroeting() {
  43. String geefBegroeting = "hallo";
  44. return geefBegroeting;
  45.  
  46. }
  47.  
  48. public static String toonHuidigeDatum() {
  49. Calendar dateTime=GregorianCalendar.getInstance();
  50. String toonHuidigeDatum = String.format("%tc%n",dateTime);
  51. return toonHuidigeDatum;
  52.  
  53.  
  54. }
  55.  
  56. public static String zetOmNaarHexadecimaal(int getal) {
  57. String zetOmNaarHexadecimaal = String.format("hexadecimale notatie (klein) = %s%n",Integer.toHexString(getal));
  58. return zetOmNaarHexadecimaal;
  59. }
  60.  
  61. public static void toonResultaat (String res)
  62. {
  63. System.out.printf("%s%n",res);
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment