Question

In: Computer Science

Write a JavaScript that calculates ideal weight for a person. A user inputs fullname, member ID,...

Write a JavaScript that calculates ideal weight for a person. A user inputs fullname, member ID, gender, height and weight. Once a user press a button, it calculates ideal weight and displays it with other information. You must implement a function that displays and calculates ideal weight. You use following formula to calculate ideal weight:

Man: Ideal Body Weight (kilograms) = [Height (cm) - 100] - ([Height (cm) - 100] x 10%)
Woman: Ideal Body Weight (kilograms) = [Height (cm) - 100] - ([Height (cm) - 100] x 15%)

Apply css style in table elements (table, tr, td) as follows:

background color - #ddeeff

border - 1 px, black color solid line

padding - 3 px

Solutions

Expert Solution

Html code:

<!DOCTYPE html>

<html>

<head>

<link rel="stylesheet" href="./bootstrap.css"/>

</head>

<body>

<div class="container">

<div class="row">

<form class="offset-md-4 col-md-5">

<div class="form-group">

<label>Full Name</label>

<input type="text" class="form-control"/>

</div>

<div class="form-group">

<label>MemberID</label>

<input type="number" class="form-control"/>

</div>

<div class="form-group">

<label>Gender</label>

<br>

<input type="radio" value="Male" name="radio"/>

<label>Male</label>&nbsp;&nbsp;&nbsp;

<input type="radio" value="Female" name="radio"/>

<label>Female</label>

</div>

<div class="form-group">

<label>Weight in Kgs</label>

<input type="number" class="form-control"/>

</div>

<div class="form-group">

<label>Height in Centimeters</label>

<input type="number" id="height" class="form-control"/>

</div>

<button class="btn btn-primary" onclick=calculate()>Calculate Ideal Weight</button>

<div >

<h3 style="color:blue" id="ideal">

</h3>

</div>

</form>

<script>

function calculate(){

event.preventDefault();

var gen = document.getElementsByName("radio");

var idealweight;

var Height=document.getElementById('height').value;

console.log(Height)

console.log(gen);

if(gen[0].checked==true)

{

idealweight= (Height-100) - ((Height-100)*0.1)

}

else if(gen[1]==true)

{

idealweight= (Height-100) - ((Height-100)*0.15)

}

document.getElementById("ideal").innerHTML="The Ideal weight of person is "+idealweight +"Kilograms";

}

</script>

</div>

</div>

</body>

</html>

Execution screenshot:


Related Solutions

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...
write a program i java that ask the user to enter salary, user ID and username...
write a program i java that ask the user to enter salary, user ID and username and out put them
In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming...
In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming distance between two strings is the number of positions at which the corresponding symbols are different. The program should output an integer representing this distance. For example a = XXWWZZ b = ZZWWXX answer = 4 More examples: "Phone" and "PHOONE" = 3 "God" and "Dog" = 2 "Dog" and "House" = 4
Write a program that prompts user to enter integers one at a time and then calculates...
Write a program that prompts user to enter integers one at a time and then calculates and displays the average of numbers entered. Use a while loop and tell user that they can enter a non-zero number to continue or zero to terminate the loop. (Switch statement) Write a program that prompts user to enter two numbers x and y, and then prompts a short menu with following 4 arithmetic operations: Chose 1 for addition Chose 2 for subtraction Chose...
Write a java program that calculates a speeding fine. The user is prompted for the speed...
Write a java program that calculates a speeding fine. The user is prompted for the speed of the vehicle, the posted speed limit and if the offence took place in the construction zone. The fine is calculated at $75 + 3$/ km over the speed limit for the first 20km over + $6 / km for the next 20 and $9/km after that. If the posted limit is 40km, the fine is doubled. If the offence took place in a...
Write a program that calculates the salary of employees. The program should prompt the user to...
Write a program that calculates the salary of employees. The program should prompt the user to enter hourly rate and number of hours of work a day. Then, the program should display the salary daily, bi-weekly (5 days a week), and monthly. Sample program: Enter your hourly rate: >>> 20 Enter how many hours you work a day: >>> 8 Your daily salary is: $160 Your bi-weekly salary is: $1600 Your monthly: $3200
Write a java program that asks the user for a positive integer N and then calculates...
Write a java program that asks the user for a positive integer N and then calculates a new value for N based on whether it is even or odd: if N is even, the new N is N/2. (Use integer division.) if N is odd, the new N is 3*N + 1. Repeat with each new N until you reach the value 1. For example, say the initial value is 12. Then the successive values are: 12 (even, next value...
write a program to calculate and print payslips write program that calculates and prints payslips. User...
write a program to calculate and print payslips write program that calculates and prints payslips. User inputs are the name of employee, numbers of hours worked and hourly rate c++ language
Write a program that calculates the amount a person would earn over a period of time...
Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should display a table showing the salary for each day, and then show the total pay at the end of the period. The output should be displayed in a dollar amount, not the number of pennies. Input Validation: Do not...
Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm...
Write a program in javascript to encrypt and decrypt the user input using the caesar algorithm with the substitution algorithm. Specify the min and max of the message user can enter to encrypt. Specify the length of the key user can enter to encrypt and decrypt the message. document your design by words or diagrams.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT