Back to .md Directory

There are two coding questions in this assignment.

Defines two Java homework assignments: string analysis with conditionals and a palindrome checker with loops.

May 2, 2026
0 downloads
1 views
ai prompt
View source

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

Java

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:

  1. Input:

    • Prompt the user to enter a sentence or phrase.
  2. 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).
  3. 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).

Grading Rubric:

CriteriaPoints
Correctness of input and output15
Proper use of String methods10
Accurate use of logical operators10
Clear and concise code structure10
Appropriate comments and formatting5
Total50

Hints:

  • Use the length(), charAt(), toUpperCase(), toLowerCase(), indexOf(), and lastIndexOf() methods of the String class.
  • 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:

  1. Input:

    • Prompt the user to enter a string.
  2. 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.
  3. Output:

    • Display whether the input string is a palindrome or not.

Grading Rubric:

CriteriaPoints
Correctness of palindrome determination15
Efficient algorithm implementation10
Clear and concise code structure10
Appropriate comments and formatting10
Proper handling of edge cases (e.g., an empty string)5
Total50

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.java with your own class name
  • Replace PalindromeChecker.java with your own class name
  • Replace BSU-devharsh/112-F24-HW2 with 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