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 33/**
44 * @author ArmeetJatyani
55 * 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:
99 * - single line comments
1010 * - multi line comments
1111 */
1212
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
1617 public static void main (String [] args ) {
1718 // this is a single line comment, I can write anything here
1819 // single line comments aren't run by Java!
@@ -22,17 +23,11 @@ public static void main(String[] args) {
2223 * this is a multi
2324 * line
2425 * comment
25- *
26+ *
2627 * It can span across multiple lines!
2728 */
2829
2930 // YOUR ASSIGNMENT: write 1 single-line comment and 1 multi-line comment on the lines below...
3031
31-
32-
33-
34-
35-
36-
3732 }
38- }
33+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
7- * Welcome to Java!
6+ *
7+ * Welcome to Java!
88 * This may be your first ever java program!
99 * We'll begin your journey with the infamous Hello World program!
1010 */
1111
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+
1415 // the main method (below) is the first thing that runs when your program is run
1516 public static void main (String [] args ) {
1617 // write code here (replace the "" with "Hello World!")
1718 System .out .println ("" );
1819 }
19- }
20+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * 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:
99 * - single line comments
1010 * - multi line comments
1111 */
1212
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
1617 public static void main (String [] args ) {
1718 // this is a single line comment, I can write anything here
1819 // single line comments aren't run by Java!
@@ -22,7 +23,7 @@ public static void main(String[] args) {
2223 * this is a multi
2324 * line
2425 * comment
25- *
26+ *
2627 * It can span across multiple lines!
2728 */
2829
@@ -31,8 +32,8 @@ public static void main(String[] args) {
3132 // Hi my name is Armeet!
3233
3334 /**
34- * I like teaching Java, and
35+ * I like teaching Java, and
3536 * good luck on your journey!
3637 */
3738 }
38- }
39+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
7- * Welcome to Java!
6+ *
7+ * Welcome to Java!
88 * This may be your first ever java program!
99 * We'll begin your journey with the infamous Hello World program!
1010 */
1111
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+
1415 // the main method (below) is the first thing that runs when your program is run
1516 public static void main (String [] args ) {
1617 // write code here (replace the "" with "Hello World!")
1718 System .out .println ("Hello World!" );
1819 }
19- }
20+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
6+ *
77 * Print out the number of apples and oranges!
88 */
99
10- public class ApplesOranges {
10+ public class ApplesOranges {
11+
1112 public static void main (String [] args ) {
1213 // write your code here
13-
14+
1415 // define an integer variable called numOranges with value 10 (line 15)
1516
16-
1717 // define an integer variable called numApples with value 24 (line 18)
1818
19-
2019 // print out number of oranges using variables, output: "I have 10 oranges." (line 21)
2120
22-
2321 // print out number of apples using variables, output: "I have 24 apples." (line 24)
2422
25-
2623 }
27- }
28-
24+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
6+ *
77 * Define different types of variables
88 */
99
10- public class VariableTypes {
10+ public class VariableTypes {
11+
1112 public static void main (String [] args ) {
1213 // write your code here
13-
14+
1415 // define an integer variable on line 15
1516
16-
1717 // define a float variable on line 18
1818
19-
2019 // define a double variable on line 21
2120
22-
2321 // define a boolean variable on line 24 (Hint: true/false)
2422
25-
2623 // define a character variable on line 27
2724
28-
29- // define a string variable on line 30
30-
25+ // define a string variable on line 30
3126
3227 }
33- }
34-
28+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
6+ *
77 * Print out the number of apples and oranges!
88 */
99
10- public class ApplesOranges {
10+ public class ApplesOranges {
11+
1112 public static void main (String [] args ) {
1213 // write your code here
13-
14+
1415 // define an integer variable called numOranges with value 10 (line 15)
1516 int numOranges = 10 ;
16-
17+
1718 // define an integer variable called numApples with value 24 (line 18)
1819 int numApples = 24 ;
19-
20+
2021 // print out number of oranges using variables, output: "I have 10 oranges." (line 21)
2122 System .out .println ("I have " + numOranges + " oranges." );
2223
2324 // print out number of apples using variables, output: "I have 24 apples." (line 24)
2425 System .out .println ("I have " + numApples + " apples." );
25-
2626 }
27- }
28-
27+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
6+ *
77 * Define different types of variables
88 */
99
10- public class VariableTypes {
11- @ SuppressWarnings ("unused" )
10+ public class VariableTypes {
11+
12+ @ SuppressWarnings ("unused" )
1213 public static void main (String [] args ) {
1314 // write your code here
14-
15+
1516 // define an integer variable on line 15
1617 int age = 23 ;
17-
18+
1819 // define a float variable on line 18
1920 float decimal = 23.32544f ;
20-
21+
2122 // define a double variable on line 21
2223 double number = 23.2352536 ;
2324
2425 // 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 :)
2627
2728 // define a character variable on line 27
2829 char letter = 'A' ;
2930
30- // define a string variable on line 30
31+ // define a string variable on line 30
3132 String name = "Jeff" ;
32-
3333 }
34- }
35-
34+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
6+ *
77 * Manage a car dealership and take inventory of all cars sold!
88 */
99
10- public class CarDealership {
10+ public class CarDealership {
11+
1112 public static void main (String [] args ) {
1213 // write your code here
13-
14- // define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
15-
1614
17-
15+ // define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
1816
1917 // 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-
2418
19+ // print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)
2520
2621 }
27- }
28-
22+ }
Original file line number Diff line number Diff line change 33/**
44 * @author ArmeetJatyani
55 * March 2021
6- *
6+ *
77 * Manage a car dealership and take inventory of all cars sold!
88 */
99
10- public class CarDealership {
10+ public class CarDealership {
11+
1112 public static void main (String [] args ) {
1213 // write your code here
13-
14+
1415 // define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
1516 final int car1 = 30000 ;
1617 final int car2 = 24650 ;
1718 final int car3 = 253630 ;
1819
1920 // define an integer variable, which represents the sum of the prices of these 3 cars (line 20)
2021 int revenue = car1 + car2 + car3 ;
21-
22+
2223 // print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)
2324 System .out .println ("I sold 3 cars for $" + revenue + "." );
24-
25-
2625 }
27- }
28-
26+ }
You can’t perform that action at this time.
0 commit comments