Due Date: March 26, 2024
PX_AdvSubstring_lastname(4 files)
Purpose: To build a java programs uses string commands.
/* Instructions:
* Copy the java program code below into Eclipse.
* I injected to 3 errors in the code.
* Find the syntax errors and correct them.
* The logic is solid. I only created syntax errors.
*/
You will need to create the following 4 files:
PX_AdvSubstring_lastname.java (Actual Java program)
PX_AdvSubstring_lastname.txt (Copy of Java program)
PX_AdvSubstring_lastname.png (Screen shot of program running)
PX_AdvSubstring_lastname.mp4 (Video of you running the program)
(You will need to verbally describe the program in your video)
Due Date: March 26, 2024
import java.util.Scanner;
public class AdvancedSubstringSearch {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input a string
System.out.print("Enter a string: ");
String inputString = scanner.nextLine();
// Input substrings to search for
System.out.print("Enter substrings to search for (comma-separated): ");
String[] substrings = scanner.nextLin().split(",");
// Ask the user if the search should be case-sensitive
System.out.printIn("Do you want the search to be case-sensitive? (yes/no): ");
boolean caseSensitive = scanner.nextLine().equalsIgnoreCase("yes");
System.out.println("\nResults:");
for (String substring : substrings) {
System.out.println("Searching for substring: " + substring);
int index = caseSensitive ? inputString.indexOf(substring) : inputString.toLowerCase().indexOf(substring.toLowerCase());
int occurrences = 0;
while (index != -1) {
occurrences++;
System.out.println("Found at index " + index);
if (index + 1 >= inputString.length()) {
break;
}
index = caseSensitive ? inputString.indexOf(substring, index + 1) : inputString.toLowerCas().indexOf(substring.toLowerCase(), index + 1);
}
if (occurrences == 0) {
System.out.println("Substring '" + substring + "' not found in the input string.");
} else {
System.out.println("Total occurrences of '" + substring + "': " + occurrences);
}
System.out.println();
}
scanner.close();
}
}
Due Date: April ?, 2024
Learn about general computer science concepts
Assignment: You will be given an exam and you will solve them on the board.
Mr. Cusack will assign you to a team.
You will need to do 10 questions on the Board at a time.
As you determine each answer, verify the answer with Mr. Cusack.
If you answer is wrong or you do not know:
You are allowed to ask Mr. Cusack questions.
Mr. Cusack may ask you to explain your answer.
Once done with all 4 groups of 10 questions,
you will need to turn them into google classroom.
(your group will be 3 or 4)
File names:
PX_2021CS_Questions_1_10.png
PX_2021CS_Questions_11_20.png
PX_2021CS_Questions_21_30.png
PX_2021CS_Questions_31_40.png