Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ui;
- import java.util.Calendar;
- import java.util.GregorianCalendar;
- import java.util.Scanner;
- public class MenuApplicatie {
- public static void main(String[] args) {
- String test;
- int keuze = toonMenuEnGeefKeuze();
- Scanner s = new Scanner(System.in);
- switch(keuze){
- case 1: test = geefBegroeting();
- break;
- case 2: test = toonHuidigeDatum();
- break;
- case 3: System.out.printf("Geef getal");
- int getal = s.nextInt();
- test = zetOmNaarHexadecimaal(getal);
- break;
- default: test = "";
- }
- toonResultaat(test);
- }
- public static int toonMenuEnGeefKeuze() {
- Scanner s = new Scanner(System.in);
- int invoer;
- do {
- System.out.printf("Menu: %n 1) Begroeting %n 2) Huidige datum %n 3) Naar Hexadecimaal %n 0) Stoppen %n Geef uw keuze%n");
- invoer = s.nextInt();
- } while (invoer>3||!(invoer>0));
- return invoer;
- }
- public static String geefBegroeting() {
- String geefBegroeting = "hallo";
- return geefBegroeting;
- }
- public static String toonHuidigeDatum() {
- Calendar dateTime=GregorianCalendar.getInstance();
- String toonHuidigeDatum = String.format("%tc%n",dateTime);
- return toonHuidigeDatum;
- }
- public static String zetOmNaarHexadecimaal(int getal) {
- String zetOmNaarHexadecimaal = String.format("hexadecimale notatie (klein) = %s%n",Integer.toHexString(getal));
- return zetOmNaarHexadecimaal;
- }
- public static void toonResultaat (String res)
- {
- System.out.printf("%s%n",res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment