CGPA to Percentage Converter
function convertCGPAToPercentage() {
// Input Validation
const cgpaInput = document.getElementById('cgpaInput');
const scaleInput = document.getElementById('scaleInput');
const resultsDiv = document.getElementById('results');
const cgpa = parseFloat(cgpaInput.value);
const scale = parseFloat(scaleInput.value);
// Comprehensive Validation
if (isNaN(cgpa) || cgpa < 0 || cgpa > scale) {
resultsDiv.innerHTML = `
Invalid CGPA!
Please enter a value between 0 and ${scale}.
`;
return;
}
// Multiple Conversion Methods
const results = {
standard: conversionMethods.standard(cgpa, scale),
linear: conversionMethods.linear(cgpa, scale),
exponential: conversionMethods.exponential(cgpa, scale)
};
// Dynamic Grading Classification
const getGradeClassification = (percentage) => {
if (percentage >= 90) return 'Outstanding';
if (percentage >= 80) return 'Excellent';
if (percentage >= 70) return 'Very Good';
if (percentage >= 60) return 'Good';
if (percentage >= 50) return 'Average';
return 'Below Average';
};
// Result Rendering
resultsDiv.innerHTML = `
Standard Conversion: ${results.standard}%
Linear Conversion: ${results.linear}%
Exponential Conversion: ${results.exponential}%
Grade Classification:
${getGradeClassification(results.standard)}
`;
}
© 2024 iguidesmart