Skip to content

Instantly share code, notes, and snippets.

@shawngrimes
Last active March 1, 2018 04:07
Show Gist options
  • Save shawngrimes/253616c58d76b555f25131f315f71418 to your computer and use it in GitHub Desktop.
Save shawngrimes/253616c58d76b555f25131f315f71418 to your computer and use it in GitHub Desktop.
Java Help
import java.util.*;
public class Bills {
public static void main(String[] args) {
double johnBills=0;
double janeBills=0;
Scanner console = new Scanner(System.in);
System.out.print("How much will John be spending? ");
johnBills = getBills();
System.out.print("How much will Jane be spending? ");
janeBills=getBills();
System.out.println("John needs " + johnBills + " bills");
System.out.println("Jane needs " + janeBills + " bills");
console.close();
}
public static double getBills (double amount) {
Scanner console = new Scanner(System.in);
amount = console.nextDouble();
System.out.println();
int numBills = (int) (amount / 20.0);
if (numBills * 20.0 < amount) {
numBills++;
}
console.close();
return numBills;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment