Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS: build question added #35

Merged
merged 1 commit into from
Oct 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions buildlogic/que1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Create a CLI app which takes name, unit test marks, pre final marks, final marks of 5 students. And then print who has the highest marks. What if I ask you to print the average as well?


// add readlineSync package
var readlineSync = require('readline-sync');

// array of questions
var questions = ["Enter your name " , "Enter unit test marks " , "Enter preFinal marks " , "Enter final marks "]

var highest = 0;
var ranker = ""


// for loop
for(var i=0; i< 5; i++){

var userName = readlineSync.question(questions[0]);
var unitMarks = readlineSync.question(questions[1]);
var preFinal = readlineSync.question(questions[2]);
var final = readlineSync.question(questions[3]);

var sum = Number(unitMarks) + Number(preFinal) + Number(final)

var avg = (sum) / 3

console.log(userName + " your Average marks from all three test is " + avg)

if(sum > highest){
highest = sum
ranker = userName
}
}

console.log("Highest scorer is: " + ranker + " whose total is: " + highest)