Created
February 28, 2019 06:39
-
-
Save AdryDev92/f0415260548a56a84e76d99b8b3e9fdb to your computer and use it in GitHub Desktop.
Simple program using calls to functions in loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class CoffeeMaker { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
int n; | |
do { | |
System.out.println("What do you want to do?\n1. Drop coffee\n2.Recharge coffee maker\n0. Exit"); | |
n = sc.nextInt(); | |
switch (n) { | |
case 1: | |
CoffeeMaker.dropCoffee(1); | |
break; | |
case 2: | |
CoffeeMaker.rechargeCafe(2); | |
break; | |
case 0: | |
System.out.println("Good bye"); | |
break; | |
} | |
} while (n != 0); | |
} | |
public static void dropCoffee(int n) { | |
if (n == 1) { | |
System.out.println("Coffee dropped\n"); | |
} | |
} | |
public static void rechargeCafe(int n) { | |
if (n == 2) { | |
System.out.println("Coffee maker recharged\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment