Skip to content

Instantly share code, notes, and snippets.

@kmb385
Created December 14, 2014 01:48
Show Gist options
  • Save kmb385/cde0409fe5ca2fd6ee86 to your computer and use it in GitHub Desktop.
Save kmb385/cde0409fe5ca2fd6ee86 to your computer and use it in GitHub Desktop.
public class Assistance {
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
String choice = null;
while(choice == null || !choice.equalsIgnoreCase("no")){
calculateBill();
System.out.println("Do you need to calculate more?");
choice = scanner.nextLine();
}
}
private static void calculateBill() {
System.out.println("How many hours:");
int hours = scanner.nextInt();
System.out.println("Whats your income:");
int income = scanner.nextInt();
doCalculation(hours, income);
}
private static void doCalculation(int hours, int income) {
//I didn't really read the instructions here but I think this gets the point across
//do some calculation
int amountOwed = hours * income; //just making this up
System.out.printf("Pay me now: %s%n", amountOwed);
scanner.nextLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment