Question

In: Computer Science

5) Write a JavaScript script that will ask the user to enter in the length of...

5) Write a JavaScript script that will ask the user to enter in the length of the side of a
cube. (all the sides of a cube are equal) Based on the value that is entered by the user
from the keyboard, calculate each of the following and assign your results to variables.
1. volume of the cube
2. surface area of the cube
3. volume of the largest sphere that could fit in the box.
4. surface area of the largest sphere that could fit in the box.
5. volume of the space in between the cube and the sphere.
HINT: the largest sphere that could fit in the box will have a diameter equal to the side
of the cube.
ANOTHER HINT: to find the volume in between the cube and sphere you should subtract
volumes. in case you forgot the sphere formulas, they are:
volume of sphere = 4/3 Pi r3
surface area of sphere = 4 Pi r2
Your script should output HTML text that displays the results of your calculations.

Solutions

Expert Solution

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

<html>

<head>Java Script </head>

<script>

function myFunction() {

var key=window.prompt("Enter Length Of Side Of The Cube:");

var pi=22/7;

var volume=key*key*key;

var surface_area=6*key*key;

var temp1=(4/3)*pi*volume;

var temp2=(4/3)*pi*key*key;

var temp3=temp1-temp2;

  

document.getElementById("1").innerHTML =volume;

document.getElementById("3").innerHTML = temp1;

document.getElementById("2").innerHTML =surface_area;

document.getElementById("4").innerHTML =temp2;

document.getElementById("5").innerHTML =temp3;

}

function myFunction1() {

var x = document.getElementById("center");

if (x.style.display === "none") {

x.style.display = "block";

} else {

x.style.display = "none";

}

}

</script>

<body onload="myFunction1()">

<center><button onclick="myFunction()">Click me</button></center>

<center>1.Volume:<p id="1"></p></center>

<center>2.Surface Area:<p id="2"></p></center>

<center>3.Volume Of Largest Sphere Fit In Box:<p id="3"></p></center>

<center>4.Surface Area Of Largest Sphere Fit In Box:<p id="4"></p></center>

<center>5.Volume Of space in B/w Cube And Sphere:<p id="5"></p></center>

</body>

</html>

Kindly revert for any queries

Thanks.


Related Solutions

In Kali Linux Write a script that ask the user to enter an IP address and...
In Kali Linux Write a script that ask the user to enter an IP address and a port number, then use the provided entries from the user to perform a query on your local network and determine if the given port is open on the provide network. Need to submit solutions for both below. 1.A short report showing the functionality of your code 2. your bash script
Write a C++ script to perform the following: a.) Ask a user to enter 2 real...
Write a C++ script to perform the following: a.) Ask a user to enter 2 real numbers. b.) Save the user response as a variable a and b. c.) Display if the numbers are even or odd. d.) Check if the number a belongs in the interval D = [10, 99], display the output as "a is between 10 and 99" or "a is not between 10 and 99". e.) Check if the number b belongs in the interval E...
Write a complete shell script that first asks the user to enter a URL. The script...
Write a complete shell script that first asks the user to enter a URL. The script should read the URL into a variable named url. The shell script should then retrieve the file associated with the URL by using the curl command. The output of the curl command should be redirected to a file named html_file. The shell script should then use the grep command to search the file named html_file for the word manhattan. Finally, the shell script should...
3. a) Write a script to prompt the user for the length and width of a...
3. a) Write a script to prompt the user for the length and width of a rectangle, and print its area with two decimal places. Put comments in the script. b) Convert the script in part (a) to a function.
Write a program that will ask the user to enter the amount of a purchase. The...
Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 5 percent and the county sales tax is 2.5 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that...
Name the script while.sh. Ask the user to enter a positive integer. You can assume that the user will enter a positive integer (input validation for a positive number not required). Use a while loop to print all integers from 0 up to and including the integer entered. Each integer should be printed on a line by itself and nothing else should print. This is for Linux. I have not done anything on this script. Please help with simplistic commands...
Task 2.5: Write a script that will ask the user for to input a file name...
Task 2.5: Write a script that will ask the user for to input a file name and then create the file and echo to the screen that the file name inputted had been created 1. Open a new file script creafile.sh using vi editor # vi creafile.sh 2. Type the following lines #!/bin/bash echo ‘enter a file name: ‘ read FILENAME touch $FILENAME echo “$FILENAME has been created” 3. Add the execute permission 4. Run the script #./creafile.sh 5. Enter...
Use a for loop to ask a user to enter the grades of 5 courses. The...
Use a for loop to ask a user to enter the grades of 5 courses. The user should enter character values, e.g., A. Calculate the GPA of the user Hint: Convert the character values entered to numerals, e.g., A to 4 c programming help me please
In python Write the code to ask a user to enter a number in the range...
In python Write the code to ask a user to enter a number in the range of 1-100. Have the code checked to make sure that it is in this range. If it is not, let the user re-enter the number. The user should be able to re-enter numbers until the number is within the correct range.
1. Write a program that will ask the user to enter a character and then classify...
1. Write a program that will ask the user to enter a character and then classify the character as one of the following using only IF-ELSE and logical operators. (50 points - 10pts for syntax, 10pts for commenting and 30pts for successful execution) • Integer • Lower Case Vowel • Upper Case Vowel • Lower Case Consonant • Upper Case Consonant • Special Character
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT