Question
need help on this assignment *It will be a console based application Your assignment is to create a program in node.js named hw3.js that can
need help on this assignment
*It will be a console based application
Your assignment is to create a program in node.js named hw3.js that can do the following operations. You need to install 'readline-sync' you can install it using npm install
-
Take four integer numbers as input from the console using 'readline-sync' like given example code. So, the user should be given a prompt for entering all 4 numbers one by one then need to press enter for getting the output. (5 points)
-
Calculate the factorial of the first number. In the console, the factorial of that first given number should be shown as an output. (5 points)
-
Calculate the sum of all the digits of the second number. For example, if we have the number 1234, the program will calculate 1+2+3+4 which is equal to 10. (5 points)
-
For the third number given as an input, show the reversed number as an output. For instance, if we give 12345 as input, it will show 54321 as output (5 points)
-
For the fourth number given as an input, check whether that number is a Palindrome or not and show the output as True in case it is a palindrome and False if it is not a palindrome. For example, if we give 12345 as an input it will return false but if we give 12321 as input, it will return true. (5 points)
Sample Input and Output:
C: \Users shibbir\Documents TA NodeJSPortable\Data>node hw3.js 1st Number: 5 2nd Number: 1234 3rd Number: 1234567 4th Number: 12321 Factorial of the 1st number is 120 The Sum of all the digits of the 2nd number10 The Reverse of the 3rd number is - 7654321 Is the 4th Number a Palindrome(True/False)?true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started