Javascript code modification in SUM and Discount on more selection

function totalIt() {
  var input = document.getElementsByName("product");
  var total = 0;
  for (var i = 0; i < input.length; i++) {
    if (input[i].checked) {
      total += parseFloat(input[i].value);
    }
  }
  document.getElementsByName("total")[0].value = "₹" + total.toFixed(2);
}

I want modify this javascript code as per below requirement.

Each check(box)’s value is 100,

  • suppose I select 1 checked(box), then output(total) should be 100 (No discount)
  • I select 2 checked(box), then Output(total) should be 150 (50% discount in 2nd selection)
  • Suppose I select 3 checked(box), then Output should(total) be 175 (50% discount in 2nd, 25% discount on 3rd selection)
  • Suppose I select 4 checked(box), then Output should(total) be 200 (50% discount in 2nd, * 25% discount on 3rd selection selection)
    Suppose I select 5 checked(box), then Output should(total) be 255 (50% discount in 2nd, 25% discount on 3rd selection selection)

Conditions:

  • No discount on first select
  • 50% discount on 2nd selection
  • After 3rd selection, each has 25% discount