the code below is a recommendation system application to suggest a suitable degree program (or
department) based on student interest and industry demand.
-main class code:
package project;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class project {
private static final int MAX_INVALID_INPUTS = 3;
private static final String LOG_FILE_PATH = "failed_attempts.txt";
public static void main(String[] args) {
SE_dep SE_obj = new SE_dep();
CSAIDepartment csaiDepartment = new CSAIDepartment();
CYDepartment cyDepartment = new CYDepartment();
DS_Dep dsDep = new DS_Dep();
double SE_minIndustSalary;
double SE_prevGPA;
String SE_interestOfStudent;
Scanner input = new Scanner(System.in);
System.out.println("Please enter the Minimum acceptable industry salary: ");
SE_minIndustSalary = validateInput(input, 10); // Maximum of 10 digits
System.out.println("Please Enter Your previous GPA: ");
SE_prevGPA = validateInput(input, 2); // Maximum of 2 digits
SE_interestOfStudent = validateInterestInput(input);
System.out.println("Student inputs: Minimum acceptable industry salary[" +
SE_minIndustSalary + "] Previous GPA[" + SE_prevGPA + "] Computer Programming
interest[" + SE_interestOfStudent + "]");
System.out.println("Suggested programs:\n\n");
SE_obj.ifIncluded_SE(SE_minIndustSalary, SE_prevGPA, SE_interestOfStudent);
cyDepartment.recommendPrograms(SE_minIndustSalary, SE_prevGPA,
SE_interestOfStudent);
csaiDepartment.recommendPrograms(SE_minIndustSalary, SE_prevGPA,
SE_interestOfStudent);
dsDep.DS_Program(SE_minIndustSalary, SE_prevGPA, SE_interestOfStudent);
double studyHours = SE_prevGPA * 1.0; // Each GPA point corresponds to 1 hour of study
int hours = (int) studyHours; // Extract the integer part (hours)
int minutes = (int) ((studyHours - hours) * 60); // Calculate the minutes
System.out.println("Required study hours (at home beside lectures): " + hours + " hours and
" + minutes + " minutes");
input.close();
}
private static double validateInput(Scanner input, int maxDigits) {
int invalidInputs = 0;
while (invalidInputs < MAX_INVALID_INPUTS) {
String userInput = input.next();
try {
double value = Double.parseDouble(userInput);
if (userInput.length() <= maxDigits) {
return value; // Input has the desired number of digits, return the value
} else {
System.out.println("Invalid input! Please enter a number with no more than " +
maxDigits + " digits: ");
invalidInputs++;
}
} catch (NumberFormatException e) {
invalidInputs++;
System.out.println("Invalid input! Please enter a valid number: ");
}
}
System.out.println("Maximum number of invalid inputs reached. Exiting...");
logFailedAttempt("Invalid input: " + input);
System.exit(0); // Terminate the program gracefully
return 0; // This line won't be executed, added to satisfy the method return type
}
private static String validateInterestInput(Scanner input) {
.
the code below is a recommendation system application to suggest a s.pdf
1. the code below is a recommendation system application to suggest a suitable degree program (or
department) based on student interest and industry demand.
-main class code:
package project;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
public class project {
private static final int MAX_INVALID_INPUTS = 3;
private static final String LOG_FILE_PATH = "failed_attempts.txt";
public static void main(String[] args) {
SE_dep SE_obj = new SE_dep();
CSAIDepartment csaiDepartment = new CSAIDepartment();
CYDepartment cyDepartment = new CYDepartment();
DS_Dep dsDep = new DS_Dep();
double SE_minIndustSalary;
double SE_prevGPA;
String SE_interestOfStudent;
Scanner input = new Scanner(System.in);
System.out.println("Please enter the Minimum acceptable industry salary: ");
SE_minIndustSalary = validateInput(input, 10); // Maximum of 10 digits
System.out.println("Please Enter Your previous GPA: ");
SE_prevGPA = validateInput(input, 2); // Maximum of 2 digits
SE_interestOfStudent = validateInterestInput(input);
System.out.println("Student inputs: Minimum acceptable industry salary[" +
SE_minIndustSalary + "] Previous GPA[" + SE_prevGPA + "] Computer Programming
interest[" + SE_interestOfStudent + "]");
System.out.println("Suggested programs:nn");
2. SE_obj.ifIncluded_SE(SE_minIndustSalary, SE_prevGPA, SE_interestOfStudent);
cyDepartment.recommendPrograms(SE_minIndustSalary, SE_prevGPA,
SE_interestOfStudent);
csaiDepartment.recommendPrograms(SE_minIndustSalary, SE_prevGPA,
SE_interestOfStudent);
dsDep.DS_Program(SE_minIndustSalary, SE_prevGPA, SE_interestOfStudent);
double studyHours = SE_prevGPA * 1.0; // Each GPA point corresponds to 1 hour of study
int hours = (int) studyHours; // Extract the integer part (hours)
int minutes = (int) ((studyHours - hours) * 60); // Calculate the minutes
System.out.println("Required study hours (at home beside lectures): " + hours + " hours and
" + minutes + " minutes");
input.close();
}
private static double validateInput(Scanner input, int maxDigits) {
int invalidInputs = 0;
while (invalidInputs < MAX_INVALID_INPUTS) {
String userInput = input.next();
try {
double value = Double.parseDouble(userInput);
if (userInput.length() <= maxDigits) {
return value; // Input has the desired number of digits, return the value
} else {
System.out.println("Invalid input! Please enter a number with no more than " +
maxDigits + " digits: ");
invalidInputs++;
}
} catch (NumberFormatException e) {
invalidInputs++;
System.out.println("Invalid input! Please enter a valid number: ");
}
}
System.out.println("Maximum number of invalid inputs reached. Exiting...");
logFailedAttempt("Invalid input: " + input);
System.exit(0); // Terminate the program gracefully
return 0; // This line won't be executed, added to satisfy the method return type
}
3. private static String validateInterestInput(Scanner input) {
int invalidInputs = 0;
while (invalidInputs < MAX_INVALID_INPUTS) {
System.out.println("Please enter Computer Programming interest (Low, Medium, High,
or Very high): ");
String userInput = input.next();
if (userInput.equalsIgnoreCase("Low") || userInput.equalsIgnoreCase("Medium")
|| userInput.equalsIgnoreCase("High") || userInput.equalsIgnoreCase("Very high")) {
return userInput;
} else {
invalidInputs++;
System.out.println("Invalid input! Please enter a valid interest level.");
}
}
System.out.println("Maximum number of invalid inputs reached. Exiting...");
logFailedAttempt("Invalid input: " + input);
System.exit(0); // Terminate the program gracefully
return ""; // This line won't be executed, added to satisfy the method return type
}
private static void logFailedAttempt(String prompt) {
try (PrintWriter writer = new PrintWriter(new FileWriter(LOG_FILE_PATH, true))) {
InetAddress ip = InetAddress.getLocalHost();
String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new
Date());
writer.println("Failed attempt at " + currentTime + " from IP: " + ip.getHostAddress());
writer.println();
} catch (IOException e) {
System.out.println("Failed to log the failed attempt.");
}}}
Note:
- The program should be written using Java language
- Need the solution Step by step