There are two coding questions in this assignment.
Defines two Java homework assignments: string analysis with conditionals and a palindrome checker with loops.
What this file does
Defines two Java homework assignments: string analysis with conditionals and a palindrome checker with loops.
When to use it
- Assigning beginner Java homework on strings and conditionals
- Creating a lab exercise for palindrome detection
- Teaching String methods and logical operators in Java
- Providing a rubric-graded programming task
Assumes this stack
There are two coding questions in this assignment.
Please write your answers in the respective Java files.
Question 1
Java Homework Assignment: String Manipulation, Logical Operators, and Conditionals
Objective:
This assignment reinforces your understanding of String manipulation, logical operators, and conditional statements in Java. You will create a program that analyzes and processes text input based on specific criteria.
Requirements:
-
Input:
- Prompt the user to enter a sentence or phrase.
-
Analysis:
- Determine the length of the input string.
- Count the number of vowels (a, e, i, o, u) in the string, ignoring case.
- Check if the string starts with a capital letter.
- Determine if the string contains the word "hello" (case-insensitive).
- Find the last occurrence of the letter 'e' in the string (if present).
-
Output:
- Display the following information:
- The length of the input string.
- The number of vowels in the string.
- Whether the string starts with a capital letter (true/false).
- Whether the string contains the word "hello" (true/false).
- The index of the last occurrence of the letter 'e' (or -1 if not found).
- Display the following information:
Grading Rubric:
| Criteria | Points |
|---|---|
| Correctness of input and output | 15 |
| Proper use of String methods | 10 |
| Accurate use of logical operators | 10 |
| Clear and concise code structure | 10 |
| Appropriate comments and formatting | 5 |
| Total | 50 |
Hints:
- Use the
length(),charAt(),toUpperCase(),toLowerCase(),indexOf(), andlastIndexOf()methods of theStringclass. - Employ logical operators (
&&,||,!) to combine conditions. - Utilize conditional statements (
if,else if,else) to make decisions based on different scenarios.
Example Output:
Enter a sentence: Hello, world!
Length of the string: 13
Number of vowels: 3
Starts with a capital letter: true
Contains "hello": true
Last occurrence of 'e': 10
Submission:
Submit your Java code file (e.g., StringAnalysis.java) along with any necessary documentation or comments.
Additional Considerations:
- Consider handling edge cases (e.g., empty input, invalid characters).
- Explore more advanced string manipulation techniques (e.g., substring, replace).
- Enhance the program to perform additional analyses or tasks based on your creativity.
Completing this assignment will solidify your understanding of essential Java concepts and develop problem-solving skills that are invaluable for programming.
Question 2
Java Homework Assignment: String Palindrome Checker
Objective:
This assignment will test your understanding of string manipulation, conditional statements, and loops in Java. You will create a program to determine whether a given input string is a palindrome.
Requirements:
-
Input:
- Prompt the user to enter a string.
-
Palindrome Check:
- Implement a function that takes a string as input and returns a boolean value indicating whether it's a palindrome.
- A palindrome is a word, phrase, number, or other sequence of characters that reads the same backward as forward.
- Ignore the case and punctuation for the palindrome check.
-
Output:
- Display whether the input string is a palindrome or not.
Grading Rubric:
| Criteria | Points |
|---|---|
| Correctness of palindrome determination | 15 |
| Efficient algorithm implementation | 10 |
| Clear and concise code structure | 10 |
| Appropriate comments and formatting | 10 |
| Proper handling of edge cases (e.g., an empty string) | 5 |
| Total | 50 |
Hints:
- Use string manipulation methods to remove punctuation and convert the string to lowercase.
- Employ loops to compare characters from the beginning and end of the string.
- Consider using a recursive approach for an alternative solution.
Example Output:
Enter a string: Race car
The string is a palindrome.
Submission:
Submit your Java code file (e.g., PalindromeChecker.java) along with any necessary documentation or comments.
Additional Considerations:
- Explore different palindrome variations (e.g., word palindromes, numeric palindromes).
- Implement optimizations for larger input strings.
- Enhance the program to handle more complex palindrome patterns.
Completing this assignment will reinforce your understanding of string manipulation, conditional logic, and algorithm design in Java.
What's inside
Two assignment descriptions, each with objective, requirements, grading rubric, hints, and example output.
Change this for your project
- Replace
StringAnalysis.javawith your own class name - Replace
PalindromeChecker.javawith your own class name - Replace
BSU-devharsh/112-F24-HW2with your repository name
Where it goes
Keep in docs/ or alongside the feature. Agents read it to implement against a defined contract.
Worth borrowing
- Rubric table with point breakdown for each criterion
- Hints section listing specific Java methods to use
Related Documents
GPU Selection Guide for Large Language Models (LLMs)
Guides GPU selection for LLM inference, fine-tuning, and training by mapping model sizes, precision levels, and budgets to VRAM requirements.
Community AI Agent Skills Discovery Sources
Catalogs 50+ platforms, repositories, directories, and communities for discovering and sharing AI agent skills across multiple coding tools.
ReleaseKit - Technical Requirements Document
Specifies a Go library and CLI for release automation with conventional commit parsing, validation checks, and workflow orchestration.
api_llm Specification
Defines a workspace of thin HTTP API clients for major LLM providers with no abstraction layer and explicit developer control.