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
Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
GalinKa [24]
A Motorcycle would be a good option or get a bike.
7 0
3 years ago
Write a statement that adds 1 to the variable reverseDrivers if the variable speed is less than 0,adds 1 to the variable parkedD
Elina [12.6K]

Answer:

if speed < 0:

 reverseDrivers +=1

elif speed < 1:

 parkedDrivers +=1

elif speed < 40:

 slowDrivers +=1

elif speed<=65:

 safeDrivers +=1

else:

 speeder +=1

Explanation:

The statements are written in python programming language

See a complete code screenshot attached, where all the variables are defined

8 0
3 years ago
You learned that properly edited resumes are necessary for making a good impression on a university or a potential employer. Dis
Daniel [21]

Answer:

it will not be a good impression and it will be hard to look for a job

Explanation:

3 0
3 years ago
I get brainlist to whoever can help my computer is doing this and I have class and it’s not working and I got it wet yesterday b
liq [111]

Answer:

try putting a lot of rice on the screen.

Explanation:

if it got water in it that should help it.

3 0
3 years ago
Read 2 more answers
After you log in to PowerPoint Online, what is the first thing you need to do to start creating a presentation?
ivann1987 [24]

Answer:

click create new presentation -_- i use power poin all the time

Explanation:

im not dum

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is working with others to find a mutually agreeable outcome?
    6·1 answer
  • While you are working with a document using a program such as wordpad, the document is stored in ___________?
    15·2 answers
  • Weather satellites orbit Earth at an altitude of 1,400,000 meters. What is this altitude in kilometers?
    7·1 answer
  • Why is it a mistake to put e-mail address of people who don't know each other in the "to:" field
    9·2 answers
  • You have been given the job of creating a new order processing system for the Yummy Fruit CompanyTM. The system reads pricing in
    8·1 answer
  • Which is said to be ‘computer on a chip’
    8·1 answer
  • An ideal line length would include how many characters? A. 6570 B. 100 C. 100125 D. 4055
    8·1 answer
  • Name three types of hard drives, along with its speed and size.
    8·1 answer
  • Are there any apps in the App Store that allow people to ask a question about any topic and have skilled professionals answer it
    6·1 answer
  • Which artificial intelligence term is used to describe extracting information from unstructured text.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!