Skip to content

Instantly share code, notes, and snippets.

@AdryDev92
Created February 28, 2019 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdryDev92/f0415260548a56a84e76d99b8b3e9fdb to your computer and use it in GitHub Desktop.
Save AdryDev92/f0415260548a56a84e76d99b8b3e9fdb to your computer and use it in GitHub Desktop.
Simple program using calls to functions in loops
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