Hammering out issues with simple calculators

Simply put, I am in a entry level computer science class, with the assignment based on fixing the html and javascript files below to create four separate working calculators. As far as I understand, however, I cannot find any formatting issues that prevent the two files from influencing each other, at least in terms of simple formatting.

function ab()
{        //
    var a; 
    var b;  
    var r;  
    a = parsefloat(document.getElementById("txt1").value);
    b = parsefloat(document.getElementById("txt2").value);
    r = a + b;
    document.getElementById("p1").innerHTML= "The sum of the numbers is " + r;


function cd()
{        //
    var c; 
    var d;  
    var r2; 
    c = parsefloat(document.getElementById("txt3").value);
    d = parsefloat(document.getElementById("txt4").value);
    r2 = c - d;
    document.getElementById("p2").innerHTML= "The sum of the numbers is" + r2;


function ef()
{        //
    var e; 
    var f;  
    var r3; 
    c = parsefloat(document.getElementById("txt5").value);
    d = parsefloat(document.getElementById("txt6").value);
    r3 = e / f;
    document.getElementById("p3").innerHTML= "The sum of the numbers is" + r3;


function gh()
{        //
    var g; 
    var h;  
    var r4; 
    c = parsefloat(document.getElementById("txt7").value);
    d = parsefloat(document.getElementById("txt8").value);
    r4 = g * f;
    document.getElementById("p4").innerHTML= "The sum of the numbers is" + r4;

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

<h1> Simple Addition</h1>

    Please type in two numbers to add them together:
    <input type="text" id="txt1" value="10"/>
    <input type="text" id="txt2" value="10"/>
    <input type="button" id ="btn1" value="Add" onclick = "ab()" />
    <p id="p1"></p>

<h1> Simple Subtraction</h1>

    Please type in two numbers to subtract them
    <input type="text" id="txt3" value="10"/>
    <input type="text" id="txt4" value="10"/>
    <input type="button" id ="btn2" value="Subtract" onclick = "cd()" />
    <p id="p2"></p>

<h1> Simple Division</h1>

    Please type in two numbers to divide them
    <input type="text" id="txt5" value="10"/>
    <input type="text" id="txt6" value="11"/>
    <input type="button" id ="btn3" value="Divide" onclick = "ef()" />
    <p id="p3"></p>

<h1> Simple Multiplication</h1>

    Please type in two numbers to multiply them
    <input type="text" id="txt7" value="10"/>
    <input type="text" id="txt8" value="10"/>
    <input type="button" id ="btn4" value="Multiply" onclick = "gh()" />
    <p id="p4"></p>


Read more here: https://stackoverflow.com/questions/68462288/hammering-out-issues-with-simple-calculators

Content Attribution

This content was originally published by Claude Turner at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: