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
Mobile phones that function as credit cards are called _____.
11111nata11111 [884]
The answer is A- Mobile Wallet
It can be used to pay for your purchases instead of using your actual card. It may be an app or it may be already built into the device. It is actually more convenient to others because you can just hold your device at the terminal when you will pay. Mobile Wallets may be smartphones or tablets.
7 0
3 years ago
Assume user_name equals "Tom" and user_age equals 22. What is printed on the console when the following statement is executed? c
12345 [234]

Answer:

The ouput of the given code is :

22

is "Tom's age.

Explanation:

Here in this code the variable user_name and user_age are initialized to  "Tom" and 22 respectively as statement is given in the question i.e  cout << user_age << " \nis " + user_name << "'s age.";.This line will print the user_age i.e 22 after that the control moves to the next line and print is "Tom's age.

Following are the code in c++

#include <iostream> // header file

#include <string>

using namespace std;

int main() // main function

{

   string user_name="Tom";

   int user_age= 22;

cout << user_age << " \nis " + user_name << "'s age.";

return 0;

}

Output:

22

is "Tom's age.

8 0
2 years ago
A customer service representative for an Internet provider uses various techniques to help a frustrated customer with a slow Int
tia_tia [17]

Answer:

“Think of it this way: When we’re done, your connection will be faster than it ever was before.”

Correct label:

positive reappraisal

“Okay, let’s put the connection speed issue aside for later and work on changing your password for our company website.”

Correct label:

distraction

“At least your router isn’t talking back at you! I can’t get my digital assistant to shut up.”

Correct label:

humor

Explanation:

4 0
3 years ago
In mathematics, "quadrant I" of the cartesian plane is the part of the plane where x and y are both positive. Given a variable,
lbvjy [14]

Answer:

#include <iostream>

using namespace std;

struct Cartesian {

double x;

double y;

};

int main() {

// creating a pointer p of type struct Cartesian

struct Cartesian *p = new Cartesian ;

cout << " Enter x: ";

// accessing the structure variable x by arrow "->"

cin >> p->x;

cout << "Enter y: ";

// accessing the structure variable y by arrow "->"

cin >> p->y;

// expression to check whether x and y lie in Quadrant 1

if (p->x > 0 && p->y > 0) {

 cout << "X and Y are in Quadrant 1 ";

}

else

{

 cout << "x And y are not in Quadrant 1";

}

// deleting the struct pointer p

delete p;

return 0;

}

Explanation:

in order to locate memory in heap, keyword "new" is used in C++ so,

struct Cartesian *p = new Cartesian ;

in order to access data members of the structure using pointer we always use an arrow "->". otherwise a dot oprerator is used to access data members.

in order to check whether x and y lie in 1st quadrent, we must use && operator in our if condition. so

if (p->x > 0 && p->y > 0)

&& will return true iff x and y both are +ve.

deleting the struct pointer p is important beacuse we are allocating memory in heap so heap memory should be used a resource and must be release when not needed otherwise it can cause memory leakage problems. so  

delete p;

5 0
3 years ago
Let's say that you handle the IT systems administration for your company. There's a server inside of your organization that chec
kirill115 [55]

From server do some file transfer to client PC to sync to the server.

<u>Explanation:</u>

As IT System administrator if PC or client or workstation or laptop not connected to network more than 3 months from windows server we need to refresh the connection and redo the connection from server to the client to do sync the activities.

Moreover from domain server refresh and re sync activities to establishing the connection.

Go to client PC or workstation or desktop login log and logout from the PC and login to domain account by changing the password.

7 0
2 years ago
Other questions:
  • Add the following functions to the code:
    9·1 answer
  • Pointsyour company environment includes windows server versions 2003, 2008, and 2012. desktops range from windows xp and vista.
    13·1 answer
  • Do you like PC? Why? (I need your opinion for research)
    10·2 answers
  • The ability to learn a new computer software program is to ____________ as knowledge of state capitals is to _____________.
    11·1 answer
  • Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in
    6·1 answer
  • What is the internet ?
    11·2 answers
  • HELP PLEASE !!!!!!!!!!!! Amy needs to ensure that she can enter a parameter that will match the values End, deadend, and flatend
    8·1 answer
  • Explain the different type of shift register counter ​
    14·1 answer
  • What is the difference between a crosstab query and a subquery?
    11·2 answers
  • What is Japanese tradition?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!