> For the complete documentation index, see [llms.txt](https://www.computersciencea.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.computersciencea.com/group/session-7.md). Agents can also search and read this documentation through its [MCP server](https://www.computersciencea.com/~gitbook/mcp).

# Session 7

## Source Code

```java
import java.util.*;

public class Session7 {
    public static void main(String[] main) {
        System.out.println("Session 7");
        
        // Example 1
        
        
        // Example 2
        
        
        // Example 3
        
        
        // Example 4
         
        
        // Example 5
        
        
        // Example 6
        
        
        // Example 7
        
        
        // Example 8
        
        
        // Example 9
        
        
        // Example 10
        
        
        // Example 11
        
        
        // Example 12
        
        
        // Example 13
        
        
        // Example 14
        
        
        // Example 15
        
        
        
        // example1 method call
        
        // example2 method call
        
        

    }
    // example1 method definition


    // example2 method definition



}
```

## S7Problem1.java

```java
import java.util.*;

public class S7Problem1 {
    public static void main(String[] args) {
        System.out.println("Problem 1");


    }
}
```

## S7Problem2.java

```java
import java.util.*;

public class S7Problem2 {
    public static void main(String[] args) {
        System.out.println("Problem 2");


    }
}
```

## S7Problem3.java

```java
import java.util.*;

public class S7Problem3 {
    public static void main(String[] args) {
        System.out.println("Problem 3");


    }
}
```

## EmailDomain.java

```java
import java.util.*;

public class EmailDomain
{
    public static String getDomain(String email)
    {
        // TODO: Use indexOf and substring only.
        // Example: "student@school.edu" → "school.edu"
        String domain;
        

        return domain;
    }

    public static void main(String[] args)
    {
        // Do not change main!
        Scanner in = new Scanner(System.in);
        System.out.print("What is your email address? ");
        String email = in.nextLine();
        System.out.println("Domain: " + getDomain(email));
        in.close();
    }
}
```

## FileExtension.java

```java
import java.util.*;

public class FileExtension
{
    public static String getExtension(String fileName)
    {
        // TODO: Use indexOf and substring only.
        // Example: "photo.jpeg" → "jpeg"
        String ext;
 

        return ext;
    }

    public static void main(String[] args)
    {
        // Do not change main!
        Scanner in = new Scanner(System.in);
        System.out.print("What is the filename? ");
        String fileName = in.nextLine();
        System.out.println("Extension: " + getExtension(fileName));
        in.close();
    }
}

```

## FirstSentence.java

```java
import java.util.*;

public class FirstSentence
{
    public static String getFirstSentence(String paragraph)
    {
        // TODO: Use indexOf and substring only.
        // Assume sentences end with a period '.'
        // Return everything up to and including the first '.'
        // Example:
        // "Today is Monday. We have class." → "Today is Monday."
        String first;
        

        return first;
    }

    public static void main(String[] args)
    {
        // Do not change main!
        Scanner in = new Scanner(System.in);
        System.out.print("What is the paragraph? ");
        String paragraph = in.nextLine();
        System.out.println("First sentence: " + getFirstSentence(paragraph));
        in.close();
    }
}

```

## AreaCode.java

```java
import java.util.*;

public class AreaCode
{
    public static String getAreaCode(String phone)
    {
        // TODO: Use indexOf and substring only.
        // Assume the phone number format is "(###) ###-####"
        // Example: "(212) 000-0000" → "212"
        String code;
        

        return code;
    }

    public static void main(String[] args)
    {
        // Do not change main!
        Scanner in = new Scanner(System.in);
        System.out.print("What is the phone number (000) 000-0000 ? ");
        String phone = in.nextLine();
        System.out.println("Area code: " + getAreaCode(phone));
        in.close();
    }
}

```

## SecretPhrase.java

```java
import java.util.*;

public class SecretPhrase
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);

        // The secret phrase
        String secret = null;

        // --- Step 1: Give the user hints ---
        

        // --- Step 2: Let the user ask questions ---
        

        // --- Step 3: Let the user guess the phrase ---


        // --- Step 4: Compare using equals()


        in.close();
    }
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.computersciencea.com/group/session-7.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
