ANSWER FOR THE ABOVE QUESTION
<script>
//part 1 answer
//declare a variable to store name
var name = "Daniel";
//declare a variable to store surname
var surname = "Kelly";
//declare a variable to store name
var age = 20;
//Print the name and surname in the same line
console.log(name+" "+surname);
//print the age in a different line
console.log(age);
//part 2 answer
//program for calculator
//declare two nuumbers
var first_number = 80;
var second_number = 20;
//code for addition
var sum = first_number+second_number;
//print result
console.log("The sum of "+first_number+" and "+second_number+" is "+sum);
//code for subtraction
var difference = first_number - second_number;
//print result
console.log("The difference of "+first_number+" and "+second_number+" is "+difference);
//code for multiplication
var product = first_number * second_number;
//print result
console.log("The product of "+first_number+" and "+second_number+" is "+product);
//code for division
var quotient = first_number * second_number;
//print result
console.log("The quotient of "+first_number+" and "+second_number+" is "+quotient);
//part 3 answer
//declare two variavles to take values of marks of two tests
var test1_mark = 78;
var test2_mark = 48;
//calculate the average
var average = (test1_mark + test2_mark)/2;
if(average < 50)
{
alert("Fail")
}
else{
alert("Pass")
}
</script>
Comments
Leave a comment