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
Which option in a Task element within Outlook indicates that the task is scheduled and will be completed on a later
joja [24]
I think it’s in progress
5 0
2 years ago
Read 2 more answers
Small programs are shortcuts that are displayed as graphics pinned to your desktop are called_____
steposvetlana [31]

Answer:

Taskbar or they are pinned to desktop

Explanation:

3 0
2 years ago
What should a web page designer consider when choosing between fixed positioning and absolute positioning?
nexus9112 [7]

Answer:

Fixed positioning is relative to the browser window, while absolute positioning is located at a specific place on a web page.

7 0
3 years ago
I need help right away pleas! 30 points.
Stolb23 [73]

Answer:

I'm very sorry if I'm wrong but I think it's A

8 0
2 years ago
Need help asapppppppppp
TEA [102]

Answer:

artistic

Explanation:

because being it is considered a art

7 0
2 years ago
Read 2 more answers
Other questions:
  • What does in-private or incognito browsing do?
    5·1 answer
  • What is the opportunity cost of computers when moving from point A to point B? -15 DVDs b. What is the opportunity cost of compu
    13·1 answer
  • to create a cover letter to send to a potential employers along with a resume what software program should you use
    10·1 answer
  • What is the name of a popular high-level computer programming and scripting language that is the name of a snake?
    10·1 answer
  • Consider the code fragment below (with nested loops). int sum = 0;for (int i = 1; i &lt; 5; i++) for (int j = 1; j &lt;= i; j++)
    15·1 answer
  • Reed Hastings created Netflix. His inspiration came from the fact that he had to pay a sizeable late fee for returning a DVD bey
    12·1 answer
  • What is network management?
    12·1 answer
  • Write a Java program to create a class called Cars. The class should include three instance variables: makes (type: String), mod
    12·1 answer
  • Write a program to prompt the user for hours worked to compute a gross pay for an employee, and he is paid 100/hour. If he worke
    7·1 answer
  • When do you use a for loop instead of a while loop? (There may be more than one answer.)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!