1. Creating a file called conversionutils.js. In this file, code the following functions:     a. centi_to_milli: Takes a value for centimeters and returns the value in millimeters.     b. meter_to_centi: Takes a value for meters and returns the value in centimeters.     c. kilo_to_meter: Takes a value for kilometers and returns the value in meters.     d. inch_to_centi: Takes a value for inches and returns the value in centimeters.     e. feet_to_centi: Takes a value for feet and returns the value in centimeters.     f. yard_to_meter: Takes a value for yards and returns the value in meters.     g. mile_to_meter: Takes a value for miles and returns the value in meters.     h. mile_to_kilo: Takes a value for miles and returns the value in kilometers.          Make sure to export your functions to make this a module.       2. Create a file called conversion.js. Start by importing your conversionutils module. When I run the conversion program, it should display a menu with all the different conversion choices. When I make a selection, it should prompt me for a value and display the conversion result by invoking the function in the module. The program should continuously display the menu until I select the exit option. The program should display an error message if I select an invalid option and prompt me until I select a valid menu option. I wrote programs but i could not run it. Please help me fix it.  1. conversionutils.js function centi_to_milli(centi) {     return centi * 10; } function meter_to_centi(meter) {     return meter * 100; } function kilo_to_meter(kilo) {     return kilo * 1000; } function inch_to_centi(inch) {     return inch * 2.54; } function feet_to_centi(feet) {     return feet * 30.48; } function yard_to_meter(yard) {     return yard * 0.9144; } function mile_to_meter(mile) {     return mile * 1609.34; } function mile_to_kilo(mile) {     return mile * 1.60934; } module.exports = {     centi_to_milli,     meter_to_centi,     kilo_to_meter,     inch_to_centi,     feet_to_centi,     yard_to_meter,     mile_to_meter,     mile_to_kilo };   2. conversion.js const readline = require('readline'); const conversionutils = require("./conversionutils"); const rl = readline.createInterface({   input: process.stdin,   output: process.stdout }); let option; while (option !== "exit") {     console.log("1. Centimeters to Millimeters");     console.log("2. Meters to Centimeters");     console.log("3. Kilometers to Meters");     console.log("4. Inches to Centimeters");     console.log("5. Feet to Centimeters");     console.log("6. Yards to Meters");     console.log("7. Miles to Meters");     console.log("8. Miles to Kilometers");     console.log("Type 'exit' to quit");     rl.question("What is your choice? ", (option) => {         if (option === "1") {         const centi = reader.questionFloat("Enter a value in centimeters: ");         const result = conversionutils.centi_to_milli(centi);         console.log(`${centi} centimeters is equal to ${result} millimeters.`);     } else if (option === "2") {         const meter = reader.questionFloat("Enter a value in meters: ");         const result = conversionutils.meter_to_centi(meter);         console.log(`${meter} meters is equal to ${result} centimeters.`);     } else if (option === "3") {         const kilo = reader.questionFloat("Enter a value in kilometers: ");         const result = conversionutils.kilo_to_meter(kilo);         console.log(`${kilo} kilometers is equal to ${result} meters.`);     } else if (option === "4") {         const inch = reader.questionFloat("Enter a value in inches: ");         const result = conversionutils.inch_to_centi(inch);         console.log(`${inch} inches is equal to ${result} centimeters.`);     } else if (option === "5") {         const feet = reader.questionFloat("Enter a value in feet: ");         const result = conversionutils.feet_to_centi(feet);         console.log(`${feet} feet is equal to ${result} centimeters.`);     } else if (option === "6") {         const yard = reader.questionFloat("Enter a value in yards: ");         const result = conversionutils.yard_to_meter(yard);         console.log(`${yard} yards is equal to ${result} meters.`);     } else if (option === "7") {         const mile = reader.questionFloat("Enter a value in miles: ");         const result = conversionutils.mile_to_meter(mile);         console.log(`${mile} miles is equal to ${result} meters.`);     } else if (option === "8") {         const mile = reader.questionFloat("Enter a value in miles: ");         const result = conversionutils.mile_to_kilo(mile);         console.log(`${mile} miles is equal to ${result} kilometers.`);     } else if (option === "exit") {         console.log("Goodbye!");     } else {         console.log("Invalid option. Please try again.");     }     rl.close(); }     )}

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

1. Creating a file called conversionutils.js. In this file, code the following functions:

    a. centi_to_milli: Takes a value for centimeters and returns the value in millimeters.
    b. meter_to_centi: Takes a value for meters and returns the value in centimeters.
    c. kilo_to_meter: Takes a value for kilometers and returns the value in meters.
    d. inch_to_centi: Takes a value for inches and returns the value in centimeters.
    e. feet_to_centi: Takes a value for feet and returns the value in centimeters.
    f. yard_to_meter: Takes a value for yards and returns the value in meters.
    g. mile_to_meter: Takes a value for miles and returns the value in meters.
    h. mile_to_kilo: Takes a value for miles and returns the value in kilometers.
    

    Make sure to export your functions to make this a module. 
    
2. Create a file called conversion.js. Start by importing your conversionutils module. When I run the conversion program, it should display a menu with all the different conversion choices. When I make a selection, it should prompt me for a value and display the conversion result by invoking the function in the module. The program should continuously display the menu until I select the exit option. The program should display an error message if I select an invalid option and prompt me until I select a valid menu option.

I wrote programs but i could not run it. Please help me fix it. 

1. conversionutils.js
function centi_to_milli(centi) {
    return centi * 10;
}

function meter_to_centi(meter) {
    return meter * 100;
}

function kilo_to_meter(kilo) {
    return kilo * 1000;
}

function inch_to_centi(inch) {
    return inch * 2.54;
}

function feet_to_centi(feet) {
    return feet * 30.48;
}

function yard_to_meter(yard) {
    return yard * 0.9144;
}

function mile_to_meter(mile) {
    return mile * 1609.34;
}

function mile_to_kilo(mile) {
    return mile * 1.60934;
}

module.exports = {
    centi_to_milli,
    meter_to_centi,
    kilo_to_meter,
    inch_to_centi,
    feet_to_centi,
    yard_to_meter,
    mile_to_meter,
    mile_to_kilo
};
 
2. conversion.js
const readline = require('readline');
const conversionutils = require("./conversionutils");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let option;

while (option !== "exit") {
    console.log("1. Centimeters to Millimeters");
    console.log("2. Meters to Centimeters");
    console.log("3. Kilometers to Meters");
    console.log("4. Inches to Centimeters");
    console.log("5. Feet to Centimeters");
    console.log("6. Yards to Meters");
    console.log("7. Miles to Meters");
    console.log("8. Miles to Kilometers");
    console.log("Type 'exit' to quit");
    rl.question("What is your choice? ", (option) => {
   
    if (option === "1") {
        const centi = reader.questionFloat("Enter a value in centimeters: ");
        const result = conversionutils.centi_to_milli(centi);
        console.log(`${centi} centimeters is equal to ${result} millimeters.`);
    } else if (option === "2") {
        const meter = reader.questionFloat("Enter a value in meters: ");
        const result = conversionutils.meter_to_centi(meter);
        console.log(`${meter} meters is equal to ${result} centimeters.`);
    } else if (option === "3") {
        const kilo = reader.questionFloat("Enter a value in kilometers: ");
        const result = conversionutils.kilo_to_meter(kilo);
        console.log(`${kilo} kilometers is equal to ${result} meters.`);
    } else if (option === "4") {
        const inch = reader.questionFloat("Enter a value in inches: ");
        const result = conversionutils.inch_to_centi(inch);
        console.log(`${inch} inches is equal to ${result} centimeters.`);
    } else if (option === "5") {
        const feet = reader.questionFloat("Enter a value in feet: ");
        const result = conversionutils.feet_to_centi(feet);
        console.log(`${feet} feet is equal to ${result} centimeters.`);
    } else if (option === "6") {
        const yard = reader.questionFloat("Enter a value in yards: ");
        const result = conversionutils.yard_to_meter(yard);
        console.log(`${yard} yards is equal to ${result} meters.`);
    } else if (option === "7") {
        const mile = reader.questionFloat("Enter a value in miles: ");
        const result = conversionutils.mile_to_meter(mile);
        console.log(`${mile} miles is equal to ${result} meters.`);
    } else if (option === "8") {
        const mile = reader.questionFloat("Enter a value in miles: ");
        const result = conversionutils.mile_to_kilo(mile);
        console.log(`${mile} miles is equal to ${result} kilometers.`);
    } else if (option === "exit") {
        console.log("Goodbye!");
    } else {
        console.log("Invalid option. Please try again.");
    }
    rl.close();
}

    )}
Expert Solution
steps

Step by step

Solved in 3 steps with 8 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY