1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Delicious77 [7]
3 years ago
8

Write a program that reads an integer (greater than 0) from the console and flips the digits of the number, using the arithmetic

operators // and %, while only printing out the even digits in the flipped order. Make sure that your program works for any number of digits and that the output does not have a newline character at the end.
Computers and Technology
1 answer:
solniwko [45]3 years ago
3 0

Answer:

const stdin = process.openStdin();

const stdout = process.stdout;

const reverse = input => {         //checks if input is number

 if (isNaN(parseInt(input))) {

   stdout.write("Input is not a number");

 }

 if (parseInt(input) <= 0) {.                       // checks if no. is positive

   stdout.write("Input is not a positive number");

 }

 let arr = [];                                  // pushing no. in array

 input.split("").map(number => {

   if (number % 2 == 0) {

     arr.push(number);

   }

 });

 console.log(arr.reverse().join(""));              // reversing the array

};

stdout.write("Enter a number: ");

let input = null;

stdin.addListener("data", text => {

 reverse(text.toString().trim());             //reversing

 stdin.pause();

});

Explanation:

In this program, we are taking input from the user and checking if it is a number and if it is positive. We will only push even numbers in the array and then reversing the array and showing it on the console.

You might be interested in
When you right-click a word with a red squiggly line under it, which of the following displays?
katovenus [111]
A spelling menu appears after right clicking 
5 0
3 years ago
Read 2 more answers
Someone help me I don’t know what to do /COMPUTER SCIENCE
nydimaria [60]
It kind of depends on the intended language, but I can see the following mistakes:

- lines not terminated with a semicolon (but not all languages require this)
- while statement missing parenthesis, ie., while (num1 <= num2), also not required in all languages
- statements below the while statement must be grouped by curly braces
- num1+5 should be num1=num1+5 or num1 += 5

Output will be:

10
15
20
25
30
5 0
4 years ago
Which of the following tasks will save a file over top of itself, using the same filename? A. Reload B. Save C. Save As D. Expor
MrRissso [65]

Answer:

B. Save is the correct option.

4 0
3 years ago
Use rounding to decide if the answer is reasonable. Write
erik [133]

Answer:

348 + 395 = 743

Hence, together they have 743 pennies and not 653 pennies. And we cannot perform the rounding, as that is the case when we have the decimal number or the float number. Only then we have the digits after the decimal. And if it's more than 5, we add 1 to the previous or else leave the number as it is. And we go on performing from right to left, and till the number of decimal places, we need to round off. However, here its purely an integer, and hence we cannot round off, as that will result in a significant loss, and which is not acceptable. However, if we want to round off before decimal places as well, then in that case 743 will be $7s, and 653 pennies will be 6+1= $7s, and if this level of loss is acceptable then we can assume that they have the same sum of money. However, here the answer is given in pennies, and hence this is not the case. And hence the answer given in the question is not correct.

Explanation:

The answer is self-explanatory. And since both are numbers, rounding is not required(as explained in the answer section), as it is required in case of decimal and float(as explained in the answer section). And as explained in the answer section, if we can tolerate very heavy loss, then the numbers as well can be rounded off as explained in the answer section. But that is not the case here, as the answer is given in pennies.

6 0
4 years ago
PLEASE HELP
Alborosie
The_____ feature of the spreadsheet will enable Susan to highlight the records.
FORMAT CELLS
3 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following indicates what a reply to all function does in most email programs
    8·1 answer
  • "A switch passes data based on the MAC address."A. TrueB. False
    15·1 answer
  • Where do you access the status report of an assigned task that is open?
    12·2 answers
  • Computer input is the process of translating physical signals (light, sound, movement) into which of the following?
    8·2 answers
  • #Write a function called "replace_all" that accepts three #arguments: # # - target_string, a string in which to search. # - find
    11·1 answer
  • When a binary tree is full to its next to last level and its leaves on the last level are filled from left to right the tree is
    14·1 answer
  • Using the world_x database you installed in Module 1, list the countries and the capitals of each country. Modify your query to
    11·1 answer
  • What is the possible output from system.out.println((int)math.random() * 4)?
    8·1 answer
  • How do you add verticse in edit mode blender
    5·1 answer
  • Slack how to enable direct message to outside workspace
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!