Skip to content

Commit

Permalink
Few indentation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakesh9100 committed Dec 12, 2024
1 parent 59ba2b1 commit 7a3192f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 87 deletions.
30 changes: 15 additions & 15 deletions Calculators/Antilog-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
function calculateAntilog() {
const number = parseFloat(document.getElementById('number').value);
const base = parseFloat(document.getElementById('base').value);
const number = parseFloat(document.getElementById('number').value);
const base = parseFloat(document.getElementById('base').value);

if (!isNaN(number) && !isNaN(base) && number > 0 && base > 0 && base !== 1) {
const result = (base) ** (number);
document.getElementById('resultb').innerText = `${result}`;
document.getElementById('result').innerText = `Antilog for base ${base} of ${number} is ${result}`;
} else {
alert('Invalid input. Please enter positive numbers greater than 0 for both the base and the number, and ensure that the base is not equal to 1.')
}
if (!isNaN(number) && !isNaN(base) && number > 0 && base > 0 && base !== 1) {
const result = (base) ** (number);
document.getElementById('resultb').innerText = `${result}`;
document.getElementById('result').innerText = `Antilog for base ${base} of ${number} is ${result}`;
} else {
alert('Invalid input. Please enter positive numbers greater than 0 for both the base and the number, and ensure that the base is not equal to 1.')
}
}

function validateBaseInput(base) {
const errorElement = document.getElementById('baseError');
if (base.value == 1) {
errorElement.style.display = 'inline';
} else {
errorElement.style.display = 'none';
}
const errorElement = document.getElementById('baseError');
if (base.value == 1) {
errorElement.style.display = 'inline';
} else {
errorElement.style.display = 'none';
}
}
10 changes: 5 additions & 5 deletions Calculators/Arrhenius-Equation-Calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<h1 class="head">Arrhenius Equation</h1>
<img src="assets/formula.png" alt="image">
<br>
k = rate constant <br>
A = pre-exponential factor <br>
E<sub>a</sub> = activation energy (in the same units as R*T) <br>
R = universal gas constant <br>
T = absolute temperature (in Kelvin) <br>
k = rate constant <br>
A = pre-exponential factor <br>
E<sub>a</sub> = activation energy (in the same units as R*T) <br>
R = universal gas constant <br>
T = absolute temperature (in Kelvin) <br>
</div>
<br>
<div id="box1">
Expand Down
8 changes: 3 additions & 5 deletions Calculators/Budget-Tracker-Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var budgetController = (function () {


/**********************
UI CONTROLLER
UI CONTROLLER
**********************/

var UIController = (function () {
Expand Down Expand Up @@ -262,9 +262,7 @@ var UIController = (function () {
})();


/**********************
APP CONTROLLER
**********************/
/********************** APP CONTROLLER **********************/

var controller = (function (budgetCtrl, UICtrl) {

Expand All @@ -287,7 +285,7 @@ var controller = (function (budgetCtrl, UICtrl) {
};

var updatePercentages = function () {
budgetCtrl.calculatePercentages(); // 1. Calculate percentages
budgetCtrl.calculatePercentages(); // 1. Calculate percentages
var percentages = budgetCtrl.getPercentages(); // 2. Read percentages from budgetCtrl
UICtrl.displayPercentages(percentages); // 3. Update UI with new percentages
};
Expand Down
86 changes: 43 additions & 43 deletions Calculators/CGPA-Percentage-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
// functions to convert values
function cgpaToPercentage(cgpa) {
return cgpa * 9.5
return cgpa * 9.5
}

function percentageToCGPA(percentage) {
return percentage / 9.5
return percentage / 9.5
}

// Function to handle conversion and display values
function convertCGPAToPercentage() {
cleanError()
let cgpaInput = parseFloat(document.getElementById('cgpaInput').value)
if (!isNaN(cgpaInput) && cgpaInput >= 0 && cgpaInput <= 10) {
let percentage = cgpaToPercentage(cgpaInput).toFixed(2)
percentageInput.value = percentage
} else {
// resetting values
cgpaInput.value = null
percentageInput.value = null
showError('Invalid CGPA. Please enter a value between 0 and 10.')
}
cleanError()
let cgpaInput = parseFloat(document.getElementById('cgpaInput').value)
if (!isNaN(cgpaInput) && cgpaInput >= 0 && cgpaInput <= 10) {
let percentage = cgpaToPercentage(cgpaInput).toFixed(2)
percentageInput.value = percentage
} else {
// resetting values
cgpaInput.value = null
percentageInput.value = null
showError('Invalid CGPA. Please enter a value between 0 and 10.')
}
}

function convertPercentageToCGPA() {
cleanError()
let percentageInput = parseFloat(
document.getElementById('percentageInput').value
)
if (
!isNaN(percentageInput) &&
percentageInput >= 0 &&
percentageInput <= 100
) {
let cgpa = percentageToCGPA(percentageInput).toFixed(2)
// for too low percentage cgpa goes negative
if (cgpa < 0) {
showError('Percentage too low')
} else {
cgpaInput.value = cgpa
}
} else {
// resetting values
cgpaInput.value = null
percentageInput.value = null
showError('Invalid Percentage. Please enter a value between 0 and 100.')
}
cleanError()
let percentageInput = parseFloat(
document.getElementById('percentageInput').value
)
if (
!isNaN(percentageInput) &&
percentageInput >= 0 &&
percentageInput <= 100
) {
let cgpa = percentageToCGPA(percentageInput).toFixed(2)
// for too low percentage cgpa goes negative
if (cgpa < 0) {
showError('Percentage too low')
} else {
cgpaInput.value = cgpa
}
} else {
// resetting values
cgpaInput.value = null
percentageInput.value = null
showError('Invalid Percentage. Please enter a value between 0 and 100.')
}
}

document.addEventListener('DOMContentLoaded', function () {
let cgpaInput = document.getElementById('cgpaInput')
let percentageInput = document.getElementById('percentageInput')
cgpaInput.addEventListener('input', convertCGPAToPercentage)
percentageInput.addEventListener('input', convertPercentageToCGPA)
let cgpaInput = document.getElementById('cgpaInput')
let percentageInput = document.getElementById('percentageInput')
cgpaInput.addEventListener('input', convertCGPAToPercentage)
percentageInput.addEventListener('input', convertPercentageToCGPA)
})

function showError(message) {
let error = document.getElementById('error')
error.innerHTML = message
let error = document.getElementById('error')
error.innerHTML = message
}

function cleanError() {
let error = document.getElementById('error')
error.innerHTML = ''
let error = document.getElementById('error')
error.innerHTML = ''
}
10 changes: 5 additions & 5 deletions Calculators/IQR-Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ calculateBtn.addEventListener('click', function () {

//adding the value inside span
resultsDiv.innerHTML = `
<p class="strong">First Quartile (Q1): <span id="q1" class="ans">${results.q1}</span></p>
<p class="strong">Third Quartile (Q3): <span id="q2" class="ans">${results.q3}</p>
<p class="strong">Interquartile Range (IQR): <span id="irq" class="ans">${results.iqr}</span></p>
<p class="strong">Minimum Value: <span id="min" class="ans">${results.min}</span></p>
<p class="strong">Maximum Value: <span id="max" class="ans">${results.max}</span></p>
<p class="strong">First Quartile (Q1): <span id="q1" class="ans">${results.q1}</span></p>
<p class="strong">Third Quartile (Q3): <span id="q2" class="ans">${results.q3}</p>
<p class="strong">Interquartile Range (IQR): <span id="irq" class="ans">${results.iqr}</span></p>
<p class="strong">Minimum Value: <span id="min" class="ans">${results.min}</span></p>
<p class="strong">Maximum Value: <span id="max" class="ans">${results.max}</span></p>
`;

});
28 changes: 14 additions & 14 deletions Calculators/Logarithm-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
function calculateLog() {
const number = parseFloat(document.getElementById('number').value);
const base = parseFloat(document.getElementById('base').value);
const number = parseFloat(document.getElementById('number').value);
const base = parseFloat(document.getElementById('base').value);

if (!isNaN(number) && !isNaN(base) && number > 0 && base > 0 && base !== 1) {
const result = Math.log(number) / Math.log(base);
document.getElementById('result').innerText = `Log base ${base} of ${number} is ${result.toFixed(4)}`;
} else {
alert('Invalid input. Please enter positive numbers for both the base and the number, and ensure that the base is not equal to 1.')
}
if (!isNaN(number) && !isNaN(base) && number > 0 && base > 0 && base !== 1) {
const result = Math.log(number) / Math.log(base);
document.getElementById('result').innerText = `Log base ${base} of ${number} is ${result.toFixed(4)}`;
} else {
alert('Invalid input. Please enter positive numbers for both the base and the number, and ensure that the base is not equal to 1.')
}
}

function validateBaseInput(base) {
const errorElement = document.getElementById('baseError');
if (base.value == 1) {
errorElement.style.display = 'inline';
} else {
errorElement.style.display = 'none';
}
const errorElement = document.getElementById('baseError');
if (base.value == 1) {
errorElement.style.display = 'inline';
} else {
errorElement.style.display = 'none';
}
}

0 comments on commit 7a3192f

Please sign in to comment.