File tree Expand file tree Collapse file tree 10 files changed +71
-93
lines changed
src/com/codefortomorrow/beginner Expand file tree Collapse file tree 10 files changed +71
-93
lines changed Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
7
- * You'll be writing your first ever comment today!
8
- * What we'll go over:
6
+ *
7
+ * You'll be writing your first ever comment today!
8
+ * What we'll go over:
9
9
* - single line comments
10
10
* - multi line comments
11
11
*/
12
12
13
- // a class is an "object" where we will place all our code inside
14
- public class Comments {
15
- // the main method (below) is the first thing that runs when your program is run
13
+ // a class is an "object" where we will place all our code inside
14
+ public class Comments {
15
+
16
+ // the main method (below) is the first thing that runs when your program is run
16
17
public static void main (String [] args ) {
17
18
// this is a single line comment, I can write anything here
18
19
// single line comments aren't run by Java!
@@ -22,17 +23,11 @@ public static void main(String[] args) {
22
23
* this is a multi
23
24
* line
24
25
* comment
25
- *
26
+ *
26
27
* It can span across multiple lines!
27
28
*/
28
29
29
30
// YOUR ASSIGNMENT: write 1 single-line comment and 1 multi-line comment on the lines below...
30
31
31
-
32
-
33
-
34
-
35
-
36
-
37
32
}
38
- }
33
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
7
- * Welcome to Java!
6
+ *
7
+ * Welcome to Java!
8
8
* This may be your first ever java program!
9
9
* We'll begin your journey with the infamous Hello World program!
10
10
*/
11
11
12
- // a class is an "object" where we will place all our code inside
13
- public class HelloWorld {
12
+ // a class is an "object" where we will place all our code inside
13
+ public class HelloWorld {
14
+
14
15
// the main method (below) is the first thing that runs when your program is run
15
16
public static void main (String [] args ) {
16
17
// write code here (replace the "" with "Hello World!")
17
18
System .out .println ("" );
18
19
}
19
- }
20
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
7
- * You'll be writing your first ever comment today!
8
- * What we'll go over:
6
+ *
7
+ * You'll be writing your first ever comment today!
8
+ * What we'll go over:
9
9
* - single line comments
10
10
* - multi line comments
11
11
*/
12
12
13
- // a class is an "object" where we will place all our code inside
14
- public class Comments {
15
- // the main method (below) is the first thing that runs when your program is run
13
+ // a class is an "object" where we will place all our code inside
14
+ public class Comments {
15
+
16
+ // the main method (below) is the first thing that runs when your program is run
16
17
public static void main (String [] args ) {
17
18
// this is a single line comment, I can write anything here
18
19
// single line comments aren't run by Java!
@@ -22,7 +23,7 @@ public static void main(String[] args) {
22
23
* this is a multi
23
24
* line
24
25
* comment
25
- *
26
+ *
26
27
* It can span across multiple lines!
27
28
*/
28
29
@@ -31,8 +32,8 @@ public static void main(String[] args) {
31
32
// Hi my name is Armeet!
32
33
33
34
/**
34
- * I like teaching Java, and
35
+ * I like teaching Java, and
35
36
* good luck on your journey!
36
37
*/
37
38
}
38
- }
39
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
7
- * Welcome to Java!
6
+ *
7
+ * Welcome to Java!
8
8
* This may be your first ever java program!
9
9
* We'll begin your journey with the infamous Hello World program!
10
10
*/
11
11
12
- // a class is an "object" where we will place all our code inside
13
- public class HelloWorld {
12
+ // a class is an "object" where we will place all our code inside
13
+ public class HelloWorld {
14
+
14
15
// the main method (below) is the first thing that runs when your program is run
15
16
public static void main (String [] args ) {
16
17
// write code here (replace the "" with "Hello World!")
17
18
System .out .println ("Hello World!" );
18
19
}
19
- }
20
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
6
+ *
7
7
* Print out the number of apples and oranges!
8
8
*/
9
9
10
- public class ApplesOranges {
10
+ public class ApplesOranges {
11
+
11
12
public static void main (String [] args ) {
12
13
// write your code here
13
-
14
+
14
15
// define an integer variable called numOranges with value 10 (line 15)
15
16
16
-
17
17
// define an integer variable called numApples with value 24 (line 18)
18
18
19
-
20
19
// print out number of oranges using variables, output: "I have 10 oranges." (line 21)
21
20
22
-
23
21
// print out number of apples using variables, output: "I have 24 apples." (line 24)
24
22
25
-
26
23
}
27
- }
28
-
24
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
6
+ *
7
7
* Define different types of variables
8
8
*/
9
9
10
- public class VariableTypes {
10
+ public class VariableTypes {
11
+
11
12
public static void main (String [] args ) {
12
13
// write your code here
13
-
14
+
14
15
// define an integer variable on line 15
15
16
16
-
17
17
// define a float variable on line 18
18
18
19
-
20
19
// define a double variable on line 21
21
20
22
-
23
21
// define a boolean variable on line 24 (Hint: true/false)
24
22
25
-
26
23
// define a character variable on line 27
27
24
28
-
29
- // define a string variable on line 30
30
-
25
+ // define a string variable on line 30
31
26
32
27
}
33
- }
34
-
28
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
6
+ *
7
7
* Print out the number of apples and oranges!
8
8
*/
9
9
10
- public class ApplesOranges {
10
+ public class ApplesOranges {
11
+
11
12
public static void main (String [] args ) {
12
13
// write your code here
13
-
14
+
14
15
// define an integer variable called numOranges with value 10 (line 15)
15
16
int numOranges = 10 ;
16
-
17
+
17
18
// define an integer variable called numApples with value 24 (line 18)
18
19
int numApples = 24 ;
19
-
20
+
20
21
// print out number of oranges using variables, output: "I have 10 oranges." (line 21)
21
22
System .out .println ("I have " + numOranges + " oranges." );
22
23
23
24
// print out number of apples using variables, output: "I have 24 apples." (line 24)
24
25
System .out .println ("I have " + numApples + " apples." );
25
-
26
26
}
27
- }
28
-
27
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
6
+ *
7
7
* Define different types of variables
8
8
*/
9
9
10
- public class VariableTypes {
11
- @ SuppressWarnings ("unused" )
10
+ public class VariableTypes {
11
+
12
+ @ SuppressWarnings ("unused" )
12
13
public static void main (String [] args ) {
13
14
// write your code here
14
-
15
+
15
16
// define an integer variable on line 15
16
17
int age = 23 ;
17
-
18
+
18
19
// define a float variable on line 18
19
20
float decimal = 23.32544f ;
20
-
21
+
21
22
// define a double variable on line 21
22
23
double number = 23.2352536 ;
23
24
24
25
// define a boolean variable on line 24 (Hint: true/false)
25
- boolean dogsOut = true ; // the dogs are out :)
26
+ boolean dogsOut = true ; // the dogs are out :)
26
27
27
28
// define a character variable on line 27
28
29
char letter = 'A' ;
29
30
30
- // define a string variable on line 30
31
+ // define a string variable on line 30
31
32
String name = "Jeff" ;
32
-
33
33
}
34
- }
35
-
34
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
6
+ *
7
7
* Manage a car dealership and take inventory of all cars sold!
8
8
*/
9
9
10
- public class CarDealership {
10
+ public class CarDealership {
11
+
11
12
public static void main (String [] args ) {
12
13
// write your code here
13
-
14
- // define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
15
-
16
14
17
-
15
+ // define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
18
16
19
17
// define an integer variable, which represents the sum of the prices of these 3 cars (line 20)
20
-
21
-
22
- // print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)
23
-
24
18
19
+ // print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)
25
20
26
21
}
27
- }
28
-
22
+ }
Original file line number Diff line number Diff line change 3
3
/**
4
4
* @author ArmeetJatyani
5
5
* March 2021
6
- *
6
+ *
7
7
* Manage a car dealership and take inventory of all cars sold!
8
8
*/
9
9
10
- public class CarDealership {
10
+ public class CarDealership {
11
+
11
12
public static void main (String [] args ) {
12
13
// write your code here
13
-
14
+
14
15
// define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
15
16
final int car1 = 30000 ;
16
17
final int car2 = 24650 ;
17
18
final int car3 = 253630 ;
18
19
19
20
// define an integer variable, which represents the sum of the prices of these 3 cars (line 20)
20
21
int revenue = car1 + car2 + car3 ;
21
-
22
+
22
23
// print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)
23
24
System .out .println ("I sold 3 cars for $" + revenue + "." );
24
-
25
-
26
25
}
27
- }
28
-
26
+ }
You can’t perform that action at this time.
0 commit comments