Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/com/codefortomorrow/beginner/chapter1/practice/Comments.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
/**
* @author ArmeetJatyani
* March 2021
*
* You'll be writing your first ever comment today!
* What we'll go over:
*
* You'll be writing your first ever comment today!
* What we'll go over:
* - single line comments
* - multi line comments
*/

// a class is an "object" where we will place all our code inside
public class Comments {
// the main method (below) is the first thing that runs when your program is run
// a class is an "object" where we will place all our code inside
public class Comments {

// the main method (below) is the first thing that runs when your program is run
public static void main(String[] args) {
// this is a single line comment, I can write anything here
// single line comments aren't run by Java!
Expand All @@ -22,17 +23,11 @@ public static void main(String[] args) {
* this is a multi
* line
* comment
*
*
* It can span across multiple lines!
*/

// YOUR ASSIGNMENT: write 1 single-line comment and 1 multi-line comment on the lines below...







}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
/**
* @author ArmeetJatyani
* March 2021
*
* Welcome to Java!
*
* Welcome to Java!
* This may be your first ever java program!
* We'll begin your journey with the infamous Hello World program!
*/

// a class is an "object" where we will place all our code inside
public class HelloWorld {
// a class is an "object" where we will place all our code inside
public class HelloWorld {

// the main method (below) is the first thing that runs when your program is run
public static void main(String[] args) {
// write code here (replace the "" with "Hello World!")
System.out.println("");
}
}
}
19 changes: 10 additions & 9 deletions src/com/codefortomorrow/beginner/chapter1/solutions/Comments.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
/**
* @author ArmeetJatyani
* March 2021
*
* You'll be writing your first ever comment today!
* What we'll go over:
*
* You'll be writing your first ever comment today!
* What we'll go over:
* - single line comments
* - multi line comments
*/

// a class is an "object" where we will place all our code inside
public class Comments {
// the main method (below) is the first thing that runs when your program is run
// a class is an "object" where we will place all our code inside
public class Comments {

// the main method (below) is the first thing that runs when your program is run
public static void main(String[] args) {
// this is a single line comment, I can write anything here
// single line comments aren't run by Java!
Expand All @@ -22,7 +23,7 @@ public static void main(String[] args) {
* this is a multi
* line
* comment
*
*
* It can span across multiple lines!
*/

Expand All @@ -31,8 +32,8 @@ public static void main(String[] args) {
// Hi my name is Armeet!

/**
* I like teaching Java, and
* I like teaching Java, and
* good luck on your journey!
*/
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
/**
* @author ArmeetJatyani
* March 2021
*
* Welcome to Java!
*
* Welcome to Java!
* This may be your first ever java program!
* We'll begin your journey with the infamous Hello World program!
*/

// a class is an "object" where we will place all our code inside
public class HelloWorld {
// a class is an "object" where we will place all our code inside
public class HelloWorld {

// the main method (below) is the first thing that runs when your program is run
public static void main(String[] args) {
// write code here (replace the "" with "Hello World!")
System.out.println("Hello World!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@
/**
* @author ArmeetJatyani
* March 2021
*
*
* Print out the number of apples and oranges!
*/

public class ApplesOranges {
public class ApplesOranges {

public static void main(String[] args) {
// write your code here

// define an integer variable called numOranges with value 10 (line 15)


// define an integer variable called numApples with value 24 (line 18)


// print out number of oranges using variables, output: "I have 10 oranges." (line 21)


// print out number of apples using variables, output: "I have 24 apples." (line 24)


}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@
/**
* @author ArmeetJatyani
* March 2021
*
*
* Define different types of variables
*/

public class VariableTypes {
public class VariableTypes {

public static void main(String[] args) {
// write your code here

// define an integer variable on line 15


// define a float variable on line 18


// define a double variable on line 21


// define a boolean variable on line 24 (Hint: true/false)


// define a character variable on line 27


// define a string variable on line 30

// define a string variable on line 30

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
/**
* @author ArmeetJatyani
* March 2021
*
*
* Print out the number of apples and oranges!
*/

public class ApplesOranges {
public class ApplesOranges {

public static void main(String[] args) {
// write your code here

// define an integer variable called numOranges with value 10 (line 15)
int numOranges = 10;

// define an integer variable called numApples with value 24 (line 18)
int numApples = 24;

// print out number of oranges using variables, output: "I have 10 oranges." (line 21)
System.out.println("I have " + numOranges + " oranges.");

// print out number of apples using variables, output: "I have 24 apples." (line 24)
System.out.println("I have " + numApples + " apples.");

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
/**
* @author ArmeetJatyani
* March 2021
*
*
* Define different types of variables
*/

public class VariableTypes {
public class VariableTypes {

@SuppressWarnings("unused")
public static void main(String[] args) {
// write your code here

// define an integer variable on line 15
int age = 23;

// define a float variable on line 18
float decimal = 23.32544f;

// define a double variable on line 21
double decimal = 23.2352536d;
double number = 23.2352536;

// define a boolean variable on line 24 (Hint: true/false)
double dogsOut = true; // the dogs are out :)
boolean dogsOut = true; // the dogs are out :)

// define a character variable on line 27
char letter = 'A';

// define a string variable on line 30
char name = "Jeff";

// define a string variable on line 30
String name = "Jeff";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@
/**
* @author ArmeetJatyani
* March 2021
*
*
* Manage a car dealership and take inventory of all cars sold!
*/

public class CarDealership {
public class CarDealership {

public static void main(String[] args) {
// write your code here

// define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)



// define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)

// define an integer variable, which represents the sum of the prices of these 3 cars (line 20)


// print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)


// print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
/**
* @author ArmeetJatyani
* March 2021
*
*
* Manage a car dealership and take inventory of all cars sold!
*/

public class CarDealership {
public class CarDealership {

public static void main(String[] args) {
// write your code here

// define 3 integer constants, representing the prices of 3 cars sold in USD (line 15-17)
final int car1 = 30000;
final int car2 = 24650;
final int car3 = 253630;

// define an integer variable, which represents the sum of the prices of these 3 cars (line 20)
int revenue = car1 + car2 + car3;

// print out the formatted revenue after selling these 3 cars, output: "I sold 3 cars for $XXXXXX." (line 23)
System.out.println("I sold 3 cars for $" + revenue + ".");


}
}

}