SlideShare a Scribd company logo
1 of 3
Download to read offline
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");
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) {
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

More Related Content

Similar to the code below is a recommendation system application to suggest a s.pdf

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujeigersonjack
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxDAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxtheodorelove43763
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfarihantmum
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docxKatecate1
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2Ankit Gupta
 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming AssignmentCoding Assignment Help
 

Similar to the code below is a recommendation system application to suggest a s.pdf (20)

Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Problemas secuenciales.
Problemas secuenciales.Problemas secuenciales.
Problemas secuenciales.
 
Estructura secuencial -garcia
Estructura secuencial -garciaEstructura secuencial -garcia
Estructura secuencial -garcia
 
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docxDAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
DAOFactory.javaDAOFactory.javapublicclassDAOFactory{ this .docx
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
 
3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf3.Lesson Plan - Input.pdf.pdf
3.Lesson Plan - Input.pdf.pdf
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
 
programming for Calculator in java
programming for Calculator in javaprogramming for Calculator in java
programming for Calculator in java
 
Java programs
Java programsJava programs
Java programs
 
JAVA Question : Programming Assignment
JAVA Question : Programming AssignmentJAVA Question : Programming Assignment
JAVA Question : Programming Assignment
 

More from rajatchugh13

tell what the program will print to the file and the screen.1. i.pdf
tell what the program will print to the file and the screen.1. i.pdftell what the program will print to the file and the screen.1. i.pdf
tell what the program will print to the file and the screen.1. i.pdfrajatchugh13
 
Task 1 Demonstrating Inheritance.pdf
Task 1 Demonstrating Inheritance.pdfTask 1 Demonstrating Inheritance.pdf
Task 1 Demonstrating Inheritance.pdfrajatchugh13
 
Suppose that you have hospital management system. The system has thr.pdf
Suppose that you have hospital management system. The system has thr.pdfSuppose that you have hospital management system. The system has thr.pdf
Suppose that you have hospital management system. The system has thr.pdfrajatchugh13
 
Suppose we have two tax systems. The first is given by the equation (i.pdf
Suppose we have two tax systems. The first is given by the equation (i.pdfSuppose we have two tax systems. The first is given by the equation (i.pdf
Suppose we have two tax systems. The first is given by the equation (i.pdfrajatchugh13
 
Subject Audit and AssuranceProjection of sample results is requ.pdf
Subject Audit and AssuranceProjection of sample results is requ.pdfSubject Audit and AssuranceProjection of sample results is requ.pdf
Subject Audit and AssuranceProjection of sample results is requ.pdfrajatchugh13
 
Stockton Company Adjusted Trial Balance December 31 Line Item Descript.pdf
Stockton Company Adjusted Trial Balance December 31 Line Item Descript.pdfStockton Company Adjusted Trial Balance December 31 Line Item Descript.pdf
Stockton Company Adjusted Trial Balance December 31 Line Item Descript.pdfrajatchugh13
 
The Diversified Portfolio Corporation provides investment advice to .pdf
The Diversified Portfolio Corporation provides investment advice to .pdfThe Diversified Portfolio Corporation provides investment advice to .pdf
The Diversified Portfolio Corporation provides investment advice to .pdfrajatchugh13
 
The concepts of blended and discrete presentation are used in financ.pdf
The concepts of blended and discrete presentation are used in financ.pdfThe concepts of blended and discrete presentation are used in financ.pdf
The concepts of blended and discrete presentation are used in financ.pdfrajatchugh13
 
specify the following Tru or false 1. In dependent variable, the .pdf
specify the following Tru or false 1. In dependent variable, the .pdfspecify the following Tru or false 1. In dependent variable, the .pdf
specify the following Tru or false 1. In dependent variable, the .pdfrajatchugh13
 
Southeastern Oklahoma State Universitys business program has the faci.pdf
Southeastern Oklahoma State Universitys business program has the faci.pdfSoutheastern Oklahoma State Universitys business program has the faci.pdf
Southeastern Oklahoma State Universitys business program has the faci.pdfrajatchugh13
 

More from rajatchugh13 (10)

tell what the program will print to the file and the screen.1. i.pdf
tell what the program will print to the file and the screen.1. i.pdftell what the program will print to the file and the screen.1. i.pdf
tell what the program will print to the file and the screen.1. i.pdf
 
Task 1 Demonstrating Inheritance.pdf
Task 1 Demonstrating Inheritance.pdfTask 1 Demonstrating Inheritance.pdf
Task 1 Demonstrating Inheritance.pdf
 
Suppose that you have hospital management system. The system has thr.pdf
Suppose that you have hospital management system. The system has thr.pdfSuppose that you have hospital management system. The system has thr.pdf
Suppose that you have hospital management system. The system has thr.pdf
 
Suppose we have two tax systems. The first is given by the equation (i.pdf
Suppose we have two tax systems. The first is given by the equation (i.pdfSuppose we have two tax systems. The first is given by the equation (i.pdf
Suppose we have two tax systems. The first is given by the equation (i.pdf
 
Subject Audit and AssuranceProjection of sample results is requ.pdf
Subject Audit and AssuranceProjection of sample results is requ.pdfSubject Audit and AssuranceProjection of sample results is requ.pdf
Subject Audit and AssuranceProjection of sample results is requ.pdf
 
Stockton Company Adjusted Trial Balance December 31 Line Item Descript.pdf
Stockton Company Adjusted Trial Balance December 31 Line Item Descript.pdfStockton Company Adjusted Trial Balance December 31 Line Item Descript.pdf
Stockton Company Adjusted Trial Balance December 31 Line Item Descript.pdf
 
The Diversified Portfolio Corporation provides investment advice to .pdf
The Diversified Portfolio Corporation provides investment advice to .pdfThe Diversified Portfolio Corporation provides investment advice to .pdf
The Diversified Portfolio Corporation provides investment advice to .pdf
 
The concepts of blended and discrete presentation are used in financ.pdf
The concepts of blended and discrete presentation are used in financ.pdfThe concepts of blended and discrete presentation are used in financ.pdf
The concepts of blended and discrete presentation are used in financ.pdf
 
specify the following Tru or false 1. In dependent variable, the .pdf
specify the following Tru or false 1. In dependent variable, the .pdfspecify the following Tru or false 1. In dependent variable, the .pdf
specify the following Tru or false 1. In dependent variable, the .pdf
 
Southeastern Oklahoma State Universitys business program has the faci.pdf
Southeastern Oklahoma State Universitys business program has the faci.pdfSoutheastern Oklahoma State Universitys business program has the faci.pdf
Southeastern Oklahoma State Universitys business program has the faci.pdf
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

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