Answer to Question #255935 in Java | JSP | JSF for junior

Question #255935
1. Write a JavaScript program that prints out name + surname (same line) and age in a new line. 2. Write a JavaScript calculator program. 3. Write a JavaScript program that calculates two tests, checks the average and if average is less than 50, prints fail in a pop-up window and if average is greater than 50, prints pass with the average in a pop-up window.
1
Expert's answer
2021-10-25T01:26:40-0400


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>


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS