Question

This is an external javascript file // Problem 1:   Declare the variables num1, num2, ans1, //  ...

This is an external javascript file

// Problem 1:   Declare the variables num1, num2, ans1,
//               greet1, greet2. Then initialize them to
//               hold the values 1, 2, 0, "Hello", and
//               "World", respectively.
var num1 = 1;
var num2 = 2;
var ans1 = 0;
var greet1 = "Hello";
var greet2 = "World";

// Problem 1a:   Display the values stored in the previous
//               variables in the console
<script>
console.log(num1);
</script>

// Problem 2:   Preform the following arithmetic using
//               the variables declared previously. Display
//               the result in the document using the ids: in1
//               in2, out1, and p2_subTitle for input1, input2,
//               output1, and subtitle, respectively.
//               1) num1 + num2
//               2) num2 - ans1
//               3) num2 * 10
//               4) num1 / 2
//               5) 21 % 7


// Problem 3:   Explain using single or multi-line
//               comments what the following is doing.
//               Then display the results on the console.
//               (Be concise and detailed when explaining)
//               1) num1 + num2 + "3"
//               2) "3" + num1 + num2


// Problem 4:   Prompt the user twice as follows:
//               "Please enter the first value: "
//               "Please enter the second value: "
//               and store the values in num1 and num2,
//               respectively. Display them in console.


// Problem 5:   Create the following program:
//               AbsoluteValue Pseudo-code (T7A slide 12)
//               get number
//               if(number < 0) then
//                   set number to (number * -1)
//               endif
//               display number


// Problem 6:   Create the following program:
//               IsPositive Psuedo-code (T7A slide 13)
//               get number
//               if(number less then 0) then
//                   display "positive"
//               otherwise
//                   display "non-positive"
//               endif


// Problem 7:   Create the following program:
//               Convert Celsius to Fahrenheit Algorithm
//               Formula: F = (C * 9/5) + 32
//       1) Declare variable named celcius and
//           fehrenheit
//       2) Prompt user to enter degree in Celcius
//           and store in appropriate variable
//       3) Calculate the Fehrenheit using formula
//           above and store in appropriate variable
//       4) Display the result as follows:
//           celcius " Celcius degrees is " fehrenheit " Fehrenheit degrees."


// Problem 8:   Display the following messages based on the
//               temperature of fehrenheit.
//               90 and above: "It's too hot man!!"
//               between 89 and 75: "It's a nice day."
//               74 and below: "It's too cold!"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution (1) ?

<script>

console.log(num1);

console.log(num2);

console.log(ans1);

console.log(greet1);

console.log(greet2);

</script>

Solution (2) ?

console.log(“Addition: ”+(num1+num2));

console.log(“Subtraction: ”+(num1-ans1));

console.log(“Multiplication: “+(num2*10));

console.log(“Division: ”+(num1/2));

console.log(“Mod: “+ (21%7))

Solution (3) ?

Single line comments:-> Single line comment is used for make a line commented which is fit in one line only and We use the (//) to comment a line.

Such as :- Single Line Comment

Multiline Comment:--> Multiline comment is used when comment is not fits in one line. We use (/*) as start and (*/) as end for multiline comment..

Such as /*This is multiline comment*/

  1. num1 + num2 + "3"

? Adding num1 and num2 and concatenating string “3” at the end of result

  1. "3" + num1 + num2

? Concatenating “3” with result of (num1+num2)

Solution (4)?

num1 = prompt("Please enter the first value: ")

num2 = prompt("Please enter the second value: ")

console.log(num1)

console.log(num2)

Solution (5) ?

num1 = prompt(“Enter number: ”)

if(num1 <0)

num1 = num1*-1

console.log(num1)

Solution (6) ?

num1 = prompt(“Enter number: ”)

if(num1 <0)

console.log(“positive”)

else

console.log(“non – positive”)

Solution (7) ?

var celcius = 0;

var fehrenheit =0;

celcius = prompt("Enter degree in celcius: ");

fehrenheit = (celcius*(9/5))+32;

console.log(celcius+" Celcius degrees is "+fehrenheit+" Fehrenheit degrees" );

Solution (8) ?

var celcius = 0;

var fehrenheit =0;

celcius = prompt("Enter degree in celcius: ");

fehrenheit = (celcius*(9/5))+32;

document.write(celcius+" Celcius degrees is "+fehrenheit+" Fehrenheit degrees" );

if (fehrenheit>=90)

console.log("It's too hot man!!")

else if(fehrenheit >=89 && fehrenheit <=75 )

console.log ("It's a nice day.")

if(fehrenheit <= 74)

console.log ("It's too cold!")

//If you need any help regarding this solution…… please leave a comment ……. thanks

Add a comment
Know the answer?
Add Answer to:
This is an external javascript file // Problem 1:   Declare the variables num1, num2, ans1, //  ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the problem with this code? <html> <body> <script type="text/javascript"> //Declare variables var numStudents; var...

    What is the problem with this code? <html> <body> <script type="text/javascript"> //Declare variables var numStudents; var index; var sName; var ES = ""; var BR = "<br />"; var PA = "<p />"; //Print statement document.write("Student Name Entry Program" + PA); //Prompt for number of students to add numStudents = prompt("Enter the number of student names to add: "+ ES); //Loop through numStudents of times, prompting for student names for(index = 1; index <= numStudents: index++) { sName = prompt("Enter...

  • I am trying to make it so that radio buttons when clicked execute a javascript file....

    I am trying to make it so that radio buttons when clicked execute a javascript file. I have to to have the exercises in external files. Here is what I have so far. I am reusing a script that was used to make radio buttons switch CSS files so I think I have to change the set attribute options. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p> 4.2 Output: The first 20 Fibonacci numbers, which are...

  • Please select the output: main         declare X as integer, Y as integer                        &nbsp

    Please select the output: main         declare X as integer, Y as integer                                 set x=1                                 set y=2                                 call sub(x, y)                                 write x                                 write y End program Subprogram sub( integer Num1 as ref, Integer Mum2 as reference)                                                              declare x as integer                                                 set Num1 = 3                                                 set Num2 = 4                                                 set x= 5                                                 write x end subprogram           Please select one:      5/42, 5/34, 5/32, 5/24 What is the output of this...

  • C++ File I/O Create a program that will work for all "infile.txt" of similar structure: The...

    C++ File I/O Create a program that will work for all "infile.txt" of similar structure: The first line will contain two integers. The first integer is the number of elements in array1, and the second integer the number of elements in array2. The second line will contain all the values of array1, and the third line will contain all values of array2. All numbers are separated by a space and all lines separated by a newline character. "infile.txt" has three...

  • What I need: Create a new program named Reverse4 and declare four integer variables with the...

    What I need: Create a new program named Reverse4 and declare four integer variables with the values 23, 45, 55, and 67. Add a method named Reverse that reverses the positions of four integer variables. The Reverse method should accept the variables as references. Write a Main() method that displays the four variables both before and after reversing them to ensure the method works correctly. What I have: using System; class Reverse4 { public static void reverse(ref int num1, ref...

  • In an external JavaScript file, you need to create two global variables for the Quarter name...

    In an external JavaScript file, you need to create two global variables for the Quarter name array and the Sales amount array. Create an anonymous function and connect it to the onclick event of the Add to Array button that adds the values from the fields (Quarter and Sales) to the respective arrays. Create an anonymous function and connect it to the onclick event of Display Sales button displays the contents of the arrays, displays the sum of all the...

  • Create a flow chart for the following problem. Declare and initialize variables Query user to enter...

    Create a flow chart for the following problem. Declare and initialize variables Query user to enter a number Add the number to a total Repeat query until the user enters a zero, then print the total and end the program

  • Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input...

    Create a CalculatorTest class that contains the main method. 1. Get two double numbers as input and create an object of the ScientificCalculator Class with those two numbers. 2. Then call the 8 operations one by one sequentially and display the result. Code must be written in Java. (Sample input/output: Enter number 1: 2 Enter number 2: 3 Add() result is : 5 Sub() result is: -1 ……. Power() result is: 8 …… sqrtNum1 result is:) The Problem: Given the...

  • *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create...

    *Answer must be in C* Write a complete program as follows (declare any necessary variables): Create an array of doubles named “hummus” with 2 rows and 300 columns. Initialize all array elements to zero. Write a loop that will repeatedly ask the user to enter a value and store it in the first row of the array (do not overwrite previously entered values) until the whole first row is populated with the user input. (hint the loop should have the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT