The real wage rate is an economic concept that measures the purchasing power of wages. It's calculated by adjusting nominal wages (the actual amount of money earned) for inflation. This means it tells you how many goods and services you can actually buy with your salary, rather than just how much money you have.
function calculateRealWage() {
var nominalWage = parseFloat(document.getElementById("nominalWage").value);
var consumerPriceIndex = parseFloat(document.getElementById("consumerPriceIndex").value);
var resultDiv = document.getElementById("result");
if (isNaN(nominalWage) || isNaN(consumerPriceIndex) || nominalWage < 0 || consumerPriceIndex <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for both nominal wage and CPI. CPI must be greater than zero.";
return;
}
// The formula for real wage is: (Nominal Wage / CPI) * 100
// This gives the equivalent wage in terms of a base year where CPI is 100.
var realWage = (nominalWage / consumerPriceIndex) * 100;
resultDiv.innerHTML = "