return meter * 100; //multiply the length value by 100, Step B } function kilo_to_meter(kilo) {

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am learning import and exports in Javascript (NOT HTML), and I have imported my first file in to the second file. The issue I am running into is its saying my num variable is not a function. I need help understanding where I went wrong in my second file. I am asking bartleby for help because all of Google talks about is html files.

This is the first file below:

function centi_to_milli(centi) {
    return centi * 10; //multiply the length value by 10, Step A
}

function meter_to_centi(meter) {
    return meter * 100; //multiply the length value by 100, Step B
}

function kilo_to_meter(kilo) {
    return kilo * 1000; //multiply the length value by 1000, Step C
}

function inch_to_centi(inch) {
    return inch * 2.54; //multiply the length value by 2.54, Step D
}

function feet_to_centi(feet) {
    return feet * 30.48; //multiply the length value by 30.48, Step E
}

function yard_to_meter(yard) {
    return yard / 1.094; //divide the length value of 1.094, Step F
}

function mile_to_meter(mile) {
    return mile * 1609; //multiply the length value by 1609, Step G
}

function mile_to_kilo(mile2){
    return mile2 * 1.60934; //multiply the length value by 1.609, Step H
}

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}

This is my second file below:

const readlineSync = require('readline-sync');
const convert = require("./conversionutils")

//import {
    //centi_to_milli,
    //meter_to_centi,
    //kilo_to_meter,
    //inch_to_centi,
    //feet_to_centi,
    //yard_to_meter,
    //mile_to_meter,
    //mile_to_kilo
//}from './conversionutils.js';

console.log("Select which converson method from the given options: ");
console.log("1. Convert centimeters to milimeters.");
console.log("2. Convert meters to centimeters.");
console.log("3. Convert kilometers to meters.");
console.log("4. Convert inches to centimeter.");
console.log("5. Convert feet to centimeters.");
console.log("6. Convert yards to meters.");
console.log("7. Convert miles to meters.");
console.log("8. Convert miles to kilometers.");

function num() {
    return parseInt(readlineSync.question("Enter your selection: "));
}

let method = convert.num();

switch (method) {
    case '1':
        let con1 = parseInt(readlineSync.question("Enter centimeters to be converted to milimeters: "))
        console.log(centi_to_milli(con1))
        break;
    case '2':
        let con2 = parseInt(readlineSync.question("Enter meters to be converted to centimeters: "))
        console.log(meter_to_centi(con2))
        break;
    case '3':
        let con3 = parseInt(readlineSync.question("Enter kilometers to be converted to meters: "))
        console.log(kilo_to_meter(con3))
        break;
    case '4':
        let con4 = parseInt(readlineSync.question("Enter inches to be converted to centimeters: "))
        console.log(inch_to_centi(con4))
        break;
    case '5':
        let con5 = parseInt(readlineSync.question("Enter feet to be converted to centimeters: "))
        console.log(feet_to_centi(con5))
        break;
    case '6':
        let con6 = parseInt(readlineSync.question("Enter yards to be converted to meters: "))
        console.log(yard_to_meter(con6))
        break;
    case '7':
        let con7 = parseInt(readlineSync.question("Enter miles to be converted to meters: "))
        console.log(mile_to_meter(con7))
        break;
    case '8':
        let con8 = parseInt(readlineSync.question("Enter miles to be converted to kilometers: "))
        console.log(mile_to_kilo(con8))
        break;
}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The while loop below does not work, I have also tried while (num != exit) and that doesn't work either. I have tried other things and the program just keeps running. I tried before I asked earlier but I was stuck again. Is there any other methods I may have over looked?

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

Thank you for that, it works great. I didn't realize the ' ' being such an issue. 

I just reread my assignment, and my prof. wants the program to continuously run until user enters the word exit.  

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education