Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions participants/Isabel/IsabelProject/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### How to run this project
1. open from project Isabel
2. run `./gradlew build` to build the project
3. Every package contains classes with main method
4. So you just can run any of them to see the output
5. For example, you can run `ArrayReverser` to see how to reverse an array in Java
56 changes: 56 additions & 0 deletions participants/Isabel/IsabelProject/UPDATE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Commit and Push Changes to the Isabel Branch

## 1. Make Changes to Your Code
Open your code editor and modify the necessary files in your project.

---

## 2. Stage Your Changes
After making changes, stage them for commit using the command:

```bash
git add .
git add <file\_name>
```
---
## 3. Commit Your Changes
```bash
git commit -m "Your descriptive commit message here"

```
---


## 4. Push Changes to Isabel Branch
```bash
git push origin Isabel
```
---

Note: This push will create a pull request on the "main" branch in the Women-Coding-Community/java-bootcamp.

# Merge Changes from the Isabel Branch to master branch

## 1. Switch to the master Branch
```bash
git checkout master
```
---
## 2. Update Main Branch (Optional)
To ensure that your main branch is up to date, run:

```bash
git pull origin master
```
---
## 3. Merge Changes from Isabel Branch
```bash
git merge Isabel
```
---
## 4. Push Merged Changes to Main Branch
```bash
git push origin master
```
---
After pushing, your changes from the Isabel branch will be merged into the remote master branch.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,32 @@ public class LifeStageBaseonAge {
//inputs 13, output: Teenager

public static void main(String[] args) {
int age = 13; // You can change this value to test with different ages; 13
// and you can create tests for that
logger.info(determineLifeStage(30));
logger.info(determineLifeStage(10));
logger.info(determineLifeStage(70));
logger.info(determineLifeStage(0));
logger.info(determineLifeStage(99));

// if it is -1 will be valid and consider as a child ;)
logger.info(determineLifeStage(-1));

// if it is 200 will be valid and consider as a Adult ;)
logger.info(determineLifeStage(200));
}

public static String determineLifeStage(int age) {
if (age <= 12) {
logger.info("Child");
return "Child";
} else if (age >= 13 && age <= 17) {
logger.info("Teenager");
return "Teenager";
} else if (age >= 18 && age <= 59) {
logger.info("Adult");
return "Adult";
} else if (age >= 60) {
logger.info("Senior Citizen");
return "Senior Citizen";
} else {
logger.warn("Invalid age input: {}", age);
//System.out.println("invalid age");
return "Invalid age";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ascii_mirror.stranger;

import java.util.Scanner;

public class Oranges_and_Apples {

public static void main(String[] args) {
//Sample Input 1:
//5
//3
//Sample Output 1:
//8

//Sample Input 2:
//10
//7
//Sample Output 2:
//17
// Use a Scanner to read user input
Scanner scanner = new Scanner(System.in);
// Read the number of apples from the user
int apples = scanner.nextInt();
int oranges = scanner.nextInt();

// Calculate the total number of fruits and print the result
int totalFruits = apples + oranges;
System.out.println(totalFruits);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static void main(String[] args) {
String age = scanner.nextLine();
//Hello, I am John! I am 22 years old.
System.out.println("Hello, I am " + name + "! I am " + age + " years old.");
scanner.close(); // Close the scanner
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,31 @@ public class ScannerInputName {
*/

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);
System.out.println("Enter 3 names::");
// Read the first name part (single token)
String name1Part1 = scanner.next();

// Read the rest of the name1 (including spaces)
String name1Part2 = scanner.nextLine();

// Combine them to form the full name1
String name1 = name1Part1 + name1Part2;
System.out.println("Enter 3 names: ");
String[] names = new String[3];

// Read the second name (which can include spaces)
String name2 = scanner.nextLine();

// Read the third name
String name3 = scanner.nextLine();

// Print the third name
System.out.println(name3);

// Split name2 into parts and print them in reverse
String[] nameParts2 = name2.split(" ");
for (int i = nameParts2.length - 1; i >= 0; i--) {
System.out.println(nameParts2[i]);
// Read exactly 3 names
for (int count = 0; count < 3; count++) {
names[count] = scanner.nextLine();
}

// Split name1 into parts and print them in reverse
String[] nameParts1 = name1.split(" ");
for (int i = nameParts1.length - 1; i >= 0; i--) {
System.out.println(nameParts1[i]);
// Print the names in reverse order
for (int i = 2; i >= 0; i--) { // Start from the last name
//input is "Jane Kate"
//Split it into pieces wherever there is a single space " ",
//Return those pieces as an array (String[]).
//So if names[i] = "Jane Kate" then:
//names[i].split(" ") becomes ["Jane", "Kate"]
//That result is stored in nameParts=["jane", "Kate"]
//split("\\s+") (split on one-or-more whitespace).
String[] nameParts = names[i].split("\\s+");
// And then printed in reverse order by the inner loop (j from end to start).
// So for "Jane Kate", it will print "Kate" first and then "Jane".
for (int j = nameParts.length - 1; j >= 0; j--) { // Print each part in reverse
System.out.println(nameParts[j]);
}
}

scanner.close(); // Close the scanner
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class ScannerOrder {

public static void main(String[] args) {

//Testing the Scanner class to read user input for a restaurant order
System.out.println("Welcome to our restaurant!");
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your name:: ");
Expand All @@ -15,9 +15,9 @@ public static void main(String[] args) {

System.out.println("Thank you, " + name + "!");
System.out.println("Your order is:: " + order);
System.out.println("=============================");

System.out.println("==========next exercise===================");

// This exercise tests the order of reading input using the Scanner class.
/** Sample Input 1:
//Hello
//Java
Expand Down