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

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
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
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 calculates the average of upto 100 English distances input by the user....
Write a program that calculates the average of upto 100 English distances input by the user. Create an array of objects of the Distance class, as in the ENGLARAY example in this chapter. To calculate the average, you can borrow the add_dist() member function from the ENGLCON example in Chapter 6. You’ll also need a member function that divides a Distance value by an integer. Here’s one possibility: void Distance::div_dist(Distance d2, int divisor) { float fltfeet = d2.feet + d2.inches/12.0;...
in C please! Write a code that asks user for input N and calculates the sum...
in C please! Write a code that asks user for input N and calculates the sum of the first N odd integers. There should be a "pure" method that calculates the sum separately that Main method should call when printing the output.
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...
in c, write a probram thats will read from the user: id, names, and marks for...
in c, write a probram thats will read from the user: id, names, and marks for a chosen number of students. the program should he able to read the total number of students from the user. Then should be able to read the id, name, and marks for each student and store it into three arrays, where each record is given in a line of text, with id, name, and marks seperated by a comma. The use of scanf is...
Write a javascript program that asks the user to enter up to 10 golf scores, which...
Write a javascript program that asks the user to enter up to 10 golf scores, which are to be stored in an array. You should provide a means for the user to terminate input prior to entering 10 scores. The program should display all the scores on one line and report the average score. Handle input, display, and the average calculation with three separate array processing functions.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT