Untitled

 avatar
unknown
plain_text
2 years ago
792 B
4
Indexable
function calculateResult(total) {
  let result = 0;

  if (total < 50.01) {
    result = multiplyBy97(total);
  } else if (total < 100.01) {
    result = multiplyBy97(50) + multiplyBy73(total - 50);
  } else if (total < 300.01) {
    result = multiplyBy97(50) + multiplyBy73(50) + multiplyBy30(total - 100);
  } else {
    result = multiplyBy97(50) + multiplyBy73(50) + multiplyBy30(200) + multiplyBy25(total - 300);
  }

  return result;
}

function multiplyBy97(number) {
  return number * 97;
}

function multiplyBy73(number) {
  return number * 73;
}

function multiplyBy30(number) {
  return number * 30;
}

function multiplyBy25(number) {
  return number * 25;
}

// Example usage
console.log(calculateResult(30));   // Output: 2910
console.log(calculateResult(301));  // Output: 14525
Editor is loading...