Advertisement
Guest User

اللغز الأول

a guest
Aug 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ex1() {
  2.         let n = parseInt(prompt("number of classes: "));
  3.         console.log(n);
  4.         let s1=0, s2=0;
  5.         for(let i=0;i<n;i++){
  6.             let note, coef;
  7.             [note, coef] = prompt(i+1+") note,coef").split(",");
  8.             console.log(i+1+") note,coef: "+note+", "+coef);
  9.             s1 += parseFloat(note)*parseInt(coef);
  10.             s2 += parseInt(coef);
  11.         }
  12.         let average = s1/s2;
  13.         console.log("average: "+average);
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement