Question

In: Computer Science

Q7: (Currency Conversion) Implement the following double functions: a) Function toAUD takes an amount in US...

Q7: (Currency Conversion) Implement the following double functions: a) Function toAUD takes an amount in US dollars and returns the AUD equivalent. b) Function toYuan takes an amount in US dollars and return the Yuan equivalent c) Use these functions to write a program that prints charts showing the AUD and Yuan equivalents of a range of dollar amounts. Print the outputs in a neat tabular format. Use an exchange rate of 1 USD = 1.42 AUD and 1 USD = 6.793 Yuan. HTML EditorKeyboard Shortcuts

Solutions

Expert Solution

<!DOCTYPE html>
<html>
    <head>
        <title>
            Currency Exchange
        </title>
    </head>
    <body>
        <input type = "number" id="audvalue" placeholder="Enter for US Dollars to AUD"/>
        <button id="ustoaud" onclick="UStoAUD()">Click here</button><span id="aud"></span> AUD
        <br>
        <br>
        <input type = "number" id="yuanvalue" placeholder="Enter for US Dollars to YUAN"/>
        <button id="ustoyuan" onclick="UStoYuan()">Click here</button><span id="yuan"></span> YUAN
        <br>
        <div><button onclick="generatechart()"> Click to generate table</button></div>
        <br>
        <table id="chart" border="2px">
            <tr>
                <th>USD</th>
                <TH>AUD</TH>
                <TH>YUAN</TH>
            </tr>
            <tr>
                <td id="1"></td>
                <td id="2"></td>
                <td id="3"></td>
            </tr>
            <tr>
                <td id="4"></td>
                <td id="5"></td>
                <td id="6"></td>
            </tr>
            <tr>
                <td id="7"></td>
                <td id="8"></td>
                <td id="9"></td>
            </tr>
        </table>
    </body>
    <script>
        function UStoAUD(){
            var value = document.getElementById("audvalue").value;
            document.getElementById("aud").innerHTML = toAUD(value)
        }
        function toAUD(value){
            return 1.42*parseFloat(value);
        }
        function UStoYuan(){
            var value = document.getElementById("yuanvalue").value;
            document.getElementById("yuan").innerHTML = toYuan(value)
        }
        function toYuan(value){
            return 6.793*parseFloat(value);
        }
        function generatechart()
        {
            var i=0;
            for(var j=1;j<=3;j++)
            {
                document.getElementById(""+(1+(j-1)*3)).innerHTML=j+"";
                document.getElementById(""+(2+(j-1)*3)).innerHTML=toAUD(j);
                document.getElementById(""+(3+(j-1)*3)).innerHTML=toYuan(j);
            }
        }
    </script>
</html>

Related Solutions

Write the following functions. Each function needs function comments that describes function and its parameters double...
Write the following functions. Each function needs function comments that describes function and its parameters double sphereVolume( double radius) double sphereSuface( double radius) double cylinderVolume( double radius, double height) double coneSurface( double radius, double height) double coneVolume( double radius, double height) That computes the volume and surface of the sphere with radius, a cylinder with a circular base with radius radius , and height height , and a cone with a circular base with radius radius , and height height...
Implement the following function: a. float temp(float t, char ch) – this function takes temperature ‘t’...
Implement the following function: a. float temp(float t, char ch) – this function takes temperature ‘t’ and unit of temperature ‘ch’ as parameter. The variable ‘ch’ will be either f or c depending on whether the temperature in variable ‘t’ is in Fahrenheit or Celsius. The function returns the converted temperature to the main method. Call the above function in the main method. Initialize temperature and unit of temperature from the user and pass them as parameter to the above...
Implement each of the following functions and write a basic main() function that tests each. For...
Implement each of the following functions and write a basic main() function that tests each. For convenience, you should be able to find this starter class under Mimir's assignment 4 starter code. Do not change the name, parameters, or returns of any of these functions or of the name of the class itself. There is also no need in this assignment for any global variables. You are strongly encouraged to use your solution for some of these functions in others...
Implement two functions in C language: stringLength() - Takes a pointer to a string, and a...
Implement two functions in C language: stringLength() - Takes a pointer to a string, and a pointer to an int variable. It computes the length of the string and updates the int variable with the length. stringCopy() - Copies one string onto another using pointers #include<stdio.h> #define MAX_STR_LEN 2048 void stringLength(char *str, int *len) { // This function computes the length of the string // at the address in the pointer *str. Once the length // has been determined, it...
Write a function in C# that takes an array of double as the parameter, and return...
Write a function in C# that takes an array of double as the parameter, and return the average
he cash conversion cycle (CCC) is a metric that illustrates the amount of time it takes...
he cash conversion cycle (CCC) is a metric that illustrates the amount of time it takes a firm to convert investments within their inventory into cash. The cash conversion cycle formula calculates the amount of time, in days, it takes for a company to turn its resource inputs into cash. The cash conversion cycle formula is: CCC = DIO + DSO – DPO Discuss the benefits the company stands to gain by accurately determining the cash conversion cycle (CCC). Discuss...
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments...
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both.
USE ONLY THE BELOW FUNCTIONS AND IMPLEMENT THE MISSING PART implement the following missing functions from...
USE ONLY THE BELOW FUNCTIONS AND IMPLEMENT THE MISSING PART implement the following missing functions from the implementation: * reset * intersection * difference Set Set::intersection(Set& s){ Set r; // find intersection return r; } Set Set::difference(Set& s){ Set r; // find difference return r; } void Set::reset(int c){ // increase the capacity and clear the data } driver program int a1[] = {10,5,7,3,9}; Set s1(5); s1.insert(a1,5); s1.print("s1"); int a2[] = {2,9,6}; Set s2(3); s2.insert(a2,3); s2.print("s2"); Set s3 = s1.unionset(s2);...
Implement the following functions in the given code: def babylonian_square_root(N, estimate, precision): This function is provided...
Implement the following functions in the given code: def babylonian_square_root(N, estimate, precision): This function is provided for you to use: def close_enough(x, y, maximum_allowable_difference): My biggest piece of advice to you is to go one line at a time and check your return values after each little change you make. Starter code: # There are different ways of implementing the same idea in math. # Today we will explore a simple way to calculate square roots. # # # #...
Design and implement a function with two input parameters, A and B. The functions then calculates...
Design and implement a function with two input parameters, A and B. The functions then calculates the result of the floor division of A over B (A//B). You are not allowed to use the floor division operator. Look at here: https://simple.wikipedia.org/wiki/Division_(mathematics) - For instance the function for 20 and 6 will return 3.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT