forked from erenuygur/EfficientHouseJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ10.java
More file actions
22 lines (18 loc) · 825 Bytes
/
Q10.java
File metadata and controls
22 lines (18 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package homeworks.chapter2;
/*
Scientists estimate that roughly 10 grams of caffeine consumed at one time is a
lethal overdose. Write a program with a variable that holds the number of milligrams of caffeine in a drink and
outputs how many drinks it takes to kill a person.
A 12-ounce can of cola has approximately 34 mg of caffeine, while a 16-ounce cup
of coffee has approximately 160 mg of caffeine.
*/
public class Q10 {
public static void main(String[] args) {
int colaCount, coffeeCount;
int milligram = 10000;
colaCount = milligram / 34;
coffeeCount = milligram / 160;
System.out.printf("If you drink %d of the 12-ounce Cokes, it's an overdose.%n", colaCount);
System.out.printf("If you drink %d of the 16-ounce Coffees, it's an overdose.", coffeeCount);
}
}