Related questions
Concept explainers
Hi! I need help with the following JAVASCRIPT programming challenge.
I need this to be done using simple and beginner level techniques and in pure javascript as in nothing meant for webpages or similar. I have provided some code that i started but I cant get it to work properly. Please use my code as reference to methods required and please help me understand where i went wrong. Thank you!!
Introduction: In this assignment we will demonstrate an understanding of functions and modules.
1. I struggle with doing metric conversions, so I'm going to have you write a conversion utility module to help me.
Start by 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.
Save your program in a folder called assignment_4. Zip that folder and submit the zip file in the dropbox.
My code:
// Functions to convert each unit to another unit//
function centi_to_milli(centi)
{
return centi * 10;
}
module.exports = centi_to_milli;
function meter_to_centi(meter)
{
return meter * 100;
}
module.exports = meter_to_centi;
function kilo_to_meter(kilo)
{
return kilo * 1000;
}
module.exports = kilo_to_meter;
function inch_to_centi(inch)
{
return inch * 2.54;
}
module.exports = inch_to_centi;
function feet_to_centi(feet)
{
return feet * 30.48;
}
module.exports = feet_to_centi;
function yard_to_meter(yard)
{
return yard * 91.44;
}
module.exports = yard_to_meter;
function mile_to_meter(mile)
{
return mile * 1609.344;
}
module.exports = mile_to_meter;
function mile_to_kilo(mile2)
{
return mile2 * 1.61;
}
module.exports = mile_to_kilo;
second file:
// Import the two modules
const centi_to_milli = require('./centi_to_milli');
const meter_to_centi = require('./meter_to_centi');
//Then, you can display the menu with the user input options:
// Display the menu
console.log('Please select an option from the menu:');
console.log('1: Convert centimeters to millimeters');
console.log('2: Convert meters to centimeters');
// Get user input
const option = prompt('Please select an option:');
// Choose the right function depending on the user input
if (option === '1')
{
const cm = prompt('Please enter the amount of centimeters:');
const mm = cmToMm(cm);
console.log(`${cm} cm is equal to ${mm} mm`);
}
else if (option === '2')
{
const m = prompt('Please enter the amount of meters:');
const cm = mToCm(m);
console.log(`${m} m is equal to ${cm} cm`);
}
else
{
console.log('Invalid option.');
}
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- What are events in jQuery and JavaScript? Could you provide some instances of events? What does the phrase "event handling" refer to? Why does event handling matter so much in interactive design? Please type since handwriting might be hard to read.arrow_forwardSoftware Engineering: The Project is: Sentiment Analysis System for Images and text, In this project, we will be creating an Sentiment Analysis system that utilizes machine learning to efficiently analyze people's feelings using their images. Then we will build a web application that is allowing users to upload an image or text and make a decision about whether it is positive, negative, or neutral. ...................................................................................................................................................... Suppose the Context models are: "Web Hosting Solution", "Internet Provider", "Database Management System", "Cloud Storage", "Monitoring and Analytics", Deep Learning, and "Colab: to execute the code". ...................................................................................................................................................... Suppose the Classes are: "User", "User Account", "Image", "Text", "Sentiment analysis system", and "Media Pre- Processing". ...................................................................................................................................................... The associations: User manages 1..1 User Account and User Account managed by 1..1 User. User uploads 1..* Image and...arrow_forwardHow does Blazor operate, in other words? What sets Razor apart from competing software? It's thought that Blazor can produce user interface elements in C# and.NET rather than JavaScript. What are the benefits and drawbacks of this arrangement in your opinion as a result?arrow_forward
- How does Blazor operate, in other words? What sets Razor apart from competing software? It's thought that Blazor can produce user interface elements in C# and.NET rather than JavaScript. What are the benefits and drawbacks of this arrangement in your opinion as a result?arrow_forwardMAKE CODE ACCORDING TO THE TEMPLATE PROVIDE AT THE END OF THE QUESTION. MATCH INPUT AND OUTPUT AS IT IS. ------------------------start--------------------------------- Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Write a C++ program to the donor and address details and display it. The class Address has the following public data members. Data Type Variable string street string city string state string country The class Donor has the following public data members. Data Type Variable string name int age float height Address address Include the following method in the Donor class. Method Member Function void displayDetails() To display all the details of a donor. In the main() method, obtain address and donor details from the user in the console and display it by calling...arrow_forwardBased on your experiences, can you show me what types of type of rendering API's have you seen when working on a 3D renderer at a large scale project. Just to give me an ideas on what typically goes into when developing a 3D renderer, that abstracts the actual graphics API's if I want to abstract the graphics API that I use to expand not just drawing primtives, but drawing geometry meshes, assets, and various other complex geometry!In C++ just to show me lots of 3D renderer API's that you might have seen from experiences and some tips you may have for someone who wants to get an idea on expanding a 3D renderer to handle rendering meshes, geometric meshes, and applying complex structures such as a scene or task graph?arrow_forward
- Hello. I am trying to answer a question for my Java programming class but I am having trouble answering. I would appreciate the help. Thanks. What is their to learn about Derived class? The derived class is said to inherit the properties of the base class, a concept called inheritance. What is their to learn about inheritance?arrow_forwardI need help with completing my Java programming project. I will be using the software Eclipse for this project so if you could also guide me through the project like labeling what is supposed to be in whatever "4 java files" or what section is what so I'm not trying to guess around, that would be great. Thank youarrow_forwardBased on your experiences in seeing various 3D rendering API's, what kind of API paradigms have you seen 3D rendering API's have used? Use C++ as the language to write these API examples. While also assuming the renderer is an abstraction of the Vulkan API.Especially in the context of an API that is expandable for rendering complex scene and task graphs. Show me lots of examples of 3D rendering API pseudo-code in C++ of how scene and task graphs would be handled by the 3D renderer when rendering frames!!!arrow_forward
- How does Blazor work? What sets Razor apart from similar applications that are available? Blazor is said to be capable of generating user interface components in C# and.NET, as opposed to utilizing JavaScript as the programming language. As a direct result of this, in your perspective, what are some of the positives and negatives associated with being in this situation?arrow_forwardMUST BE IN JAVA. PLEASE USE COMMENTS AND WRITE THE CODE IN SIMPLEST FORM.arrow_forwardThis question is in the course of Python programming language as an OOP. I need the answer ASAP. Full instructions below. Any code/project that satisfies the requirements is acceptable.Thank you so much!1- At least one superclass should be used in the project2- There must be at least two subclasses in the project3- Each class must have a constructor function4- Each class must have at least 4 object attributes that are not included in other defined classes5- Each class must have at least 4 methods that are not included in other defined classes6- Within the four methods in the base class, there should be two methods defined as @classmethod and @staticmethod7- Use override only once, override method8- Use encapsulation only once. (use a hidden property and property decorator.)9- Create two objects of any class.arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education