Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Prepare a userform to help calculate the cost of electricity for Oklahoma Reside

ID: 3777918 • Letter: P

Question

Prepare a userform to help calculate the cost of electricity for Oklahoma Residential customers. A textbox should be created to write the name of the customer. Another textbox should be created to write the consumption per month of electricity in kwh. 3 Option buttons should exist to choose from the three different seasons that the electrical company uses to calculate the cost using three different formulas as seen below. Finally a textbox should be created where the result will be written m the following way "The cost of electricity for John Doe is $50.00" where the name of the customer and the actual cost will be variables. In Oklahoma OGE uses the following way to calculate residential electricity cost: There is always a flat service fee of $13.00 per customer. There are three seasons Summer (June-September), Winter (November-April), and Shoulder Season (May and October) The cost for each month belonging to a season is calculated as follows: SUMMER MONTH: first 1400 kWh 5.73 cents/kwh and every kwh after that 6.80 cents/kwh WINTER MONTH: first 600 kWh 5.73 cents/kwh and every kwh after that 1.73 cents/kwh SHOULDER MONTH. 5.73 cents/kwh Generate a userform using the data provided that when called it will have a combobox containing the names of key hydrocarbons, methane, ethane, n-propane, n-butane, n-pentane, n-hexane, n-heptane, and n-octane. Three option buttons will appear selecting for the units of temperature (degree C, F, K). A Textbox will be added where the temperature number will be entered. A set of checkboxes will be added selecting the units of pressure (Atm, Bar, mmHg, psia). Unlike the example in class only one pressure unit is allowed. The final textbox will present to vapor pressure of the selected hydrocarbon for the selected temperature in the selected units of pressure (with the value and the units appearing in the textbox). Finally we need at the bottom a CALCULATE button, a CLEAR button, and a CANCEL button as we did in the class example. Try to make it look nice. Compound Name A B C methane 6.69561 405.42 267.777 ethane 6.83452 663.7 256.47 propane 6.80398 803.81 246.99 butane 6.80896 935.86 238.73 pentane 6.87632 1075.78 233.205 hexane 6.87024 1168.72 224.21 heptane 6.89385 1264.37 216.636 octane 6.9094 1349.82 209.385

Explanation / Answer

Hello,

Here goes the solution for Question 1 using HTML and Javascript for calculating the bill

Javascript: script.js

function calculate(){
var name=document.getElementById("name").value;
var consumption=document.getElementById("cons").value;
var cat=document.querySelector('input[name = "cat"]:checked').value
var bill=13;
if(cat=="s"){
    if(consumption>=1400){
      consumption=consumption-1400;
      bill=consumption*0.0680+1400*0.0573;
    }else{
      bill=consumption*0.0573;
    }  
}else if(cat=="w"){
    if(consumption>=600){
      consumption=consumption-600;
      bill=consumption*0.0173+600*0.573;
    }else{
      bill=consumption*0.573;
    }
}else{
    bill=bill+0.0573*consumption;  
}

var printString="The cost of electricity for "+name+" is $"+bill ;
document.getElementById("result").value=printString;
}

HTML:index.html

<!DOCTYPE html>
<html>

<head>
    <script src="script.js"></script>
</head>

<body>
    Name of the consumer: <input type="text" id="name"><br/>
    Consumption per month in kwh:<input type="number" id="cons"><br/>
    <input type="radio" id="cat" name="cat" value="s" checked> Summer<br>
    <input type="radio" id="cat" name="cat" value="w"> Winter<br>
    <input type="radio" id="cat" name="cat" value="ss"> Shoulder Season<br/>
    <button>submit</button><br/>
    <input type="text" id="result">
</body>

</html>

If any formulas are changed you can edit the javascript code to reflect the respective changes!