Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I need help with some Java Programming. I have attached a few screenshots

ID: 3905580 • Letter: H

Question

Hello, I need help with some Java Programming. I have attached a few screenshots that show what the requirements of the application and what the results must look like. If you could help and post a screenshot of the finished code and what it looks like in the compiler, that would be great.

Validate User Input Using Java Chars and Strings In this assessment, you will design and code a Java console application that validates the data entry of a course code (like IT4782) and report back if the course code is valid or not valid. The application uses the Java char and String data types to implement the validation. You can use either the Toolwire environment or your local Java development environment to complete this assignment. The requirements of this application are as follows: The application is to read a course code entered by the user from the keyboard. The course code is made of 5 characters and should followw these rules First character is always an upper case I or a lower case i Second character is always an upper case T or a lower case t . Third, fourth, fifth, and sixth characters are always digits (0-9) The application then validates the course code against above the rules and prints a message if the course code is valid or not. If the course code is not valid, the application should print a message explaining why the course code is not valid Use these course codes to test your application IT4782 IT4782 OT4782 it&782 Successful completion of this assignment will show a valid message or an invalid message for the entered course code. In addition, if the course code is invalid, the application should identify the reason for the invalidation. Your program output should look like this sample output

Explanation / Answer

Below is your code.Please do rate this answer positive, If i was able to help you. Let me know if you have any issues in comments

public class Validation {

public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter a course code to validate (e.g. IT4782): ");
String code = s.nextLine();
if (validateCode(code)) {
System.out.println(code+" is valid.");
} else {
System.out.println(code+" is not valid.");
}
}

private static boolean validateCode(String code) {
if (code.length() != 6) {
return false;
} else {
//First character is always an upper case I or a lower case i
if (code.charAt(0) != 'I' && code.charAt(0) != 'i') {
return false;
}
// Second character is always an upper case T or a lower case t
if (code.charAt(1) != 'T' && code.charAt(1) != 't') {
return false;
}
// Third, fourth, fifth, and sixth characters are always digits (0-9)
if (!Character.isDigit(code.charAt(2))) {
return false;
}
if (!Character.isDigit(code.charAt(3))) {
return false;
}
if (!Character.isDigit(code.charAt(4))) {
return false;
}
if (!Character.isDigit(code.charAt(5))) {
return false;
}
return true;
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote