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
trapecia [35]
3 years ago
6

Write a program with class name Digits that prompts the user to input a positive integer and then outputs the number reversed an

d the sum of the digits. For example, if the user enters the number 3456, then your program should output 6543 and the sum as 18. Use a while loop. Hint: use the mod operator and 10 as divider to find the right most digit and to update the value of controlling expression
Computers and Technology
1 answer:
mr Goodwill [35]3 years ago
7 0

Answer:

Written in Python:

inputnum = int(input("User Input: "))

outputnum = 0

total = 0

while(inputnum>0):

     remainder = inputnum % 10

     outputnum = (outputnum * 10) + remainder

     inputnum = inputnum//10

     total = total + remainder

print("Reverse: "+str(outputnum))

print("Total: "+str(total))

Explanation:

This prompts user for input

inputnum = int(input("User Input: "))

This initializes the reverse number to 0

outputnum = 0

This initializes total to 0; i.e. sum of each digit

total = 0

The following iteration gets the reverse of user input

<em>while(inputnum>0): </em>

<em>      remainder = inputnum % 10 </em>

<em>      outputnum = (outputnum * 10) + remainder </em>

<em>      inputnum = inputnum//10 </em>

<em>      This adds each digit of user input</em>

<em>      total = total + remainder </em>

This prints the reversed number

print("Reverse: "+str(outputnum))

This prints the sum of each digit

print("Total: "+str(total))

You might be interested in
In modern computer systems, a byte consists of
Cerrena [4.2K]
8 smaller units, called bits :)
8 0
3 years ago
Top/Bottom Rules allow a user to apply conditional formatting to cells that fall within the top or bottom numbers or percentile.
Aliun [14]

C. TRUST

Explanation:

7 0
3 years ago
Read 2 more answers
What command would you use to copy the content of a file named report1 to another called report1uc. Convert the content of repor
Ray Of Light [21]

Answer:

Answered below.

Explanation:

This answer is applicable to Linux.

There are several commands for copying files in Linux. cp and rsync are the most widely used. cp though, is the command used to copy files and their contents.

To copy a file named report1.txt to another file named report1uc.txt in the current directory, the following command is run.

$ cp report1.txt report1uc.txt

You can change the case of the strings in the file by using the tr command.

tr [:lower:] [:upper:]

For example,

$ echo brainly | tr [:lower:]. [:upper:]

Result is BRAINLY.

7 0
3 years ago
Ok so another weird question! So if you know what google drive is and how to upload a video why does it keep adding hours! it ke
lesya [120]

Answer:Your video may be too long and you may not have that much storage left.

Explanation:

5 0
3 years ago
Which extension is appropriate for Word document templates?
expeople1 [14]
The answer to this question is A
8 0
2 years ago
Read 2 more answers
Other questions:
  • Once the technology for the collection of solar power is in place what will be two benefits of its use
    9·1 answer
  • Emily is an aspiring lyricist. She wants to make a demo tape to send to recording companies. Which input device can she use to r
    5·1 answer
  • By changing the field size for text to the maximum number necessary,
    6·1 answer
  • Domain of (x+8)/(x(x+10))
    12·1 answer
  • Graphs and charts are two different elements. True or False
    15·1 answer
  • What is the difference, if any, between an alpha test group and a beta test group? An alpha test group is made up of people asso
    9·1 answer
  • Which of the following information should be included in audit documentation? a. Procedures performed. b. Audit evidence examine
    13·1 answer
  • 15 points. Please give an actual answer and not some random thing. this is not just free points. Correct answer will receive bra
    12·2 answers
  • why does planets orbit the sun? asap i give brainlist i know it on that subject i dont know what else goes with it
    10·1 answer
  • What is a document you can create with word-processing software
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!