Question

In: Computer Science

Problem: Design a web page to provide a metric conversion guide for college students. Provide the...

Problem: Design a web page to provide a metric conversion guide for college students. Provide the capability to convert the following (both ways):

Miles to kilometers (distance)

Gallons to liters (volume)

Pounds to kilograms (weight)

Fahrenheit to Celsius (temperature)


must have a separate PHP and HTML page

Solutions

Expert Solution

HTML Source code for converting Miles to Kilometers

<html>
<head><title>Miles to Kilometers</title>
<script language="javascript">

var textMiles;
  var textKm;
   var KILOMETERS_TO_MILES = 0.621371;
  var MILES_TO_KM = 1.60934;
   function initElements() {
    if (!textMiles) {  // Intitialization of the elements
      textMiles = document.getElementById("text-miles");
      textKm = document.getElementById("text-km");
    }
  }
 
  function calMilesFromKilometers() {
    initElements();
    var km = parseFloat(txtKm.value);
    txtMiles.value = String(km * MILES_TO_KM);//Formula to calculate the conversion rate of the KM into miles
  }
 
  function calcKilometersFromMiles() {
    initElements();
    var miles = parseFloat(txtMiles.value);
    txtKm.value = String(miles * KM_TO_MILES);//formula to calculate KM_to_Miles

}

</script>

</head>

<body>

 <body>
 <b>Miles To Kilometers Converter</b> <br>
<br>
 <table border="0" cellpadding="5" cellspacing="0" style="width: 500px;">
<tbody>
  <tr>
    <td> </td>
    <td><b>Miles</b>  </td>
    <td> </td>
    <td><b>Kilometers</b>  </td>
  </tr>
  <tr>
    <td>miles: </td>
    <td><input id="txt-miles" size="20" type="text" value="50"/> </td>
    <td>km: </td>
    <td><input id="txt-km" size="20" type="text" value=""/> </td>
  </tr>
  <tr>
    <td> </td>
    <td> <button type="button" onclick="calcMilesFromKilometers();">Calculate Miles</button> </td>
    <td> </td>
    <td> <button type="button" onclick="calcKilometersFromMiles();">Calculate Kilometers</button> </td>
  </tr>
</table>
 </body>
</html>
The above HTML Program would help the user to write a script and execute the script in the HTML Program.
__________________________________________________________________

2.Gallons to Litres

<html> 
<head> <script language="Java script">
 $(function () {  // set values  var toGallons = 0.26417; 
 var toMetric = 3.7854;  
var converted = 0;  
$('input[name="data"]').change(function () {  // convert the value to  convert();   });
 $('input[name="convert"]').change(function () {  // change radip to convert  convert();  }); 
 function convert() {  var theValue = $('input[name="data"]').val(); //value of original  
var selected = $("input[type='radio'][name='convert']:checked").val(); //determine if Metric or Imperial    if (selected === 'i') { //If imperial  converted = "The Imperial Value of " + theValue + " = the metric value of " + theValue * toMetric;  } else {//If metric  converted = "The Metric Value of " + theValue + " = the Imperial value of " + theValue * toGallons;  }  $('#newData').html(converted); //Place new data in div id newData   } });  </script>
<title>Gallons to litres conversion</title>
 </head> 
<body> <input type="radio" name="convert" value="m">
Metric <input type="radio" name="convert" value="i" checked>
Imperial  <div>Data<br><input name="data" value="0"> 
</div>  
  <div>Converted</div><div id="newData"></div>  
  </body>
 </html>
___________________________________________________________________

3. HTML Program to convert pounds to kilogram
<html>
<head>
<script language="java script">
function weightConverter(valNum) {

{
document.getElementById("outputGrams").innerHTML=valNum/0.0022046;
}

</script>
</head>
<body>

<p>
  <label>Pounds</label>
  <input id="inputPounds" type="number" placeholder="Pounds"  oninput="weightConverter(this.value)"onchange="weightConverter(this.value)">
</p>
<p>Grams: <span id="outputGrams"></span></p>

</body>

</html>

________________________________________________________________________

We need to use the Math.round() method for the conversion

HTML Program to convert fareign heit to celsius

<html>
<body>

<h1>JavaScript Fahrenheit to Celsius</h1>//heading

<p>Insert a number into one of the input fields below:</p>

<p><input id="f" onkeyup="convert('F')"> degrees Fahrenheit</p>

<p><input id="c" onkeyup="convert('C')"> degrees Celsius</p>

<script>

function convert(degree) {
var x;
if (degree == "C") {
x = document.getElementById("c").value * 5 / 9 - 32;
document.getElementById("f").value = Math.round(x);
} else {
x = (document.getElementById("f").value +32) * 9 /5;
document.getElementById("c").value = Math.round(x);
}
}
</script>

</body>
</html>

___________________________________________________________________________

The above method can help the user to enter the values and conversion formulas in script language.


Related Solutions

A movie monopolist sells to college students and other adults, as in Worked-Out Problem 18.2 (page...
A movie monopolist sells to college students and other adults, as in Worked-Out Problem 18.2 (page 635). The demand function for students is           QdS=1,000−100P, and the demand function for other adults is           QdA=4,500−100P. Marginal cost is $2 per ticket. Instructions: Round your answers to 2 decimal places. a. What prices will the monopolist set when she can discriminate? How will discrimination affect the monopolist's profit?          Pstudent = $ per ticket.     Padult = $ per ticket....
Basic guide to developing a research design ( Please provide EXAMPLES in terms to Politics !!)...
Basic guide to developing a research design ( Please provide EXAMPLES in terms to Politics !!) 1. What are the treatment and outcome variables? How are they defined and measured? 2. What are the two (or more) groups in your research? That is, what is the treatment group and what is the control group? a. How is the treatment assigned to the group? Random vs. selected by something else? If not randomly assigned, what determines the assignment of the treatment?...
Design an activities page to make this web site complete. a.Use your imagination to create at...
Design an activities page to make this web site complete. a.Use your imagination to create at least four activities. b.Organize these activities in a table. c.Some activities are free but some may charge some fee. d.Once again, the correct resort title and navigation menu bar shall be included.e.Include an image for each activity. Make sure the images’ size are the same.f.When mouse hovers on any image, its size will be enlarged.
You have been asked to design a web page for a local business or organization (choose...
You have been asked to design a web page for a local business or organization (choose one from your local community). Go to www.flickr.com or www.1StopPictures.com and choose a visual to illustrate the website by trying to match the personality of the organization to a visual image. Then, identify the primary categories of information that need to be included on the page. Develop a flow chart or map that shows how a typical user would navigate through the site. What...
You are asked to provide a lecture about corporate finance for college students. Provide a detailed...
You are asked to provide a lecture about corporate finance for college students. Provide a detailed explanation of corporate finance and the main role of financial managers in 500 words.
Problem Description Write a web page that allows a person to enter address information, salutation, and...
Problem Description Write a web page that allows a person to enter address information, salutation, and a prize amount. Place a button at the bottom of the page that, which clicked, displays the contents of a letter informing them that they've won
Problem 2) In absence of special preparation, according to the data from the College Board Web...
Problem 2) In absence of special preparation, according to the data from the College Board Web site, half of students taking the SAT math exam scored above the national average. An educational researcher was interested in the effectiveness of SAT coaching classes on improving SAT math scores. Specifically, his study looked at whether a higher proportion of coached students scored above the national average than for students who had not been coached. He selected a random sample of 953 students...
Design and implement an application that can compute the weekly pay for different students at a college.
In Java Design and implement an application that can compute the weekly pay for different students at a college. Students (all with a name, major, GPA) can be undergraduate or graduate students. Undergraduate students can be volunteers to be tuto rs or teaching assistants. Graduate students can be teaching assistants or research assistants. Volunteer tuto rs are not paid anything. Undergraduate teaching assistants are paid $15 per hour and can work a maximum of 20 hours per week. Graduate teaching assistants...
Design and implement a program to allow a college administrator to register new students and add...
Design and implement a program to allow a college administrator to register new students and add courses to the existing one. In addition, your program should allow the administrator to do the following: • Add/Remove a new student • Add/Remove a course to/from a selected student • Search for a student either by last name or by id. • Search for a course either by name or by id. • Display a selected student along with the courses s/he is...
Problem 4: In a sample of 1000 Yuba College students, it was found that they consumed...
Problem 4: In a sample of 1000 Yuba College students, it was found that they consumed on average 23 grams of sugar with a standard deviation of 4 grams and that 230 planned to transfer to Chico State. a) (7 points) Can we conclude with 99% confidence that Yuba College students consume on average over 20 grams of sugar? Use the rejection region approach. (7 points) Can we conclude with 99% confidence that under 25% of Yuba College students plan...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT