forked from Nnamdikeshi/Java2545examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoreNumberVariables.java
More file actions
38 lines (23 loc) · 996 Bytes
/
Copy pathMoreNumberVariables.java
File metadata and controls
38 lines (23 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package week1_variables_if_else;
public class MoreNumberVariables {
public static void main(String args[]) {
//create some variables
int zebras = 4;
System.out.println("There are " + zebras + " zebras.");
int cats = 6;
System.out.println("There are " + cats + " cats.");
//Some math with these ints
int animals = cats + zebras;
System.out.println("There are " + animals + " animals altogether.");
//Print an empty line
System.out.println();
//Create some double variables, and some more int variables
double widgetPrice = 4.57;
int widgetsNeeded = 56;
double shippingPrice = 22.33;
double allWidgetCost = widgetPrice * widgetsNeeded;
System.out.println("Total widget cost is $" + allWidgetCost);
double widgetsPlusShipping = allWidgetCost + shippingPrice;
System.out.printf("Total with shipping is $" + widgetsPlusShipping);
}
}