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?...
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
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 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...
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...
Dr. Page believes that going through a training program will decrease weekly exercise. College students exercise...
Dr. Page believes that going through a training program will decrease weekly exercise. College students exercise an average of 2.2 days a week with a variance of 2.25 days. Dr. Page's sample of 28 students exercise an average of 1.6 days a week. What can be concluded with an α of 0.01? a) What is the appropriate test statistic? ---Select one--- (na, z-test, one-sample t-test, independent-samples t-test, or related-samples t-test) b) Population: ---Select one--- ((exercise), college students, days in the...
Dr. Page believes that going through a training program will decrease weekly reading. College students read...
Dr. Page believes that going through a training program will decrease weekly reading. College students read a mean of 2.3 days a week with a variance of 0.49 days. Dr. Page's sample of 31 students read a mean of 1.9 days a week. What can be concluded with α = 0.01? a) What is the appropriate test statistic? ---Select--- na z-test one-sample t-test independent-samples t-test related-samples t-test b) Population: ---Select--- (reading) college students days in the week individuals exposed to...
Problem 1      A survey of 1000 college students shows what they like to do with...
Problem 1      A survey of 1000 college students shows what they like to do with their time      Below is are the results of the survey      Activity Percentage      Attending College 9%      Sleeping 24%      Socializing 51%      Studying 7%      Working 9%      Answer the following questions based on the data above      a. Construct a bar chart, a pie chart and a Pareto Chart. Place the charts starting in column H      b. Which graphical...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT