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
andrew11 [14]
4 years ago
7

Design a program that asks the user to enter a string containing a series of single digit numbers with nothing separating them.

The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4. (Hint: The stringToInteger library function can be used to convert a single character to an integer.)
Computers and Technology
1 answer:
ruslelena [56]4 years ago
7 0

Answer:

  1. def calcSum(d):
  2.    sum = 0
  3.    for x in d:
  4.        sum += int(x)
  5.    return sum
  6. digits = input("Please enter your digits: ")
  7. print(calcSum(digits))

Explanation:

The solution code is written in Python.

Firstly, create a function that take one input digit string (Line 1).

In the function, create a sum variable with initial value 0.

Use a for loop to traverse through each character in the digit string and in the loop use int method to convert each character to integer and add it to sum variable (Line 3-5) and return the sum as output.

Next, use input function to prompt user enter a digit string (Line 7).

Lastly test the function by passing the input digit as argument and print the result (Line 8).

You might be interested in
What is one reason the number of DUIs has dropped?
nikdorinn [45]

Answer:

Ride Sharing Services

Explanation:

Choosing to take Uber or have a designated driver instead of driving under the influence than have fewer students because fewer people are getting caught diving under the influence.

8 0
3 years ago
PLZ HELP 100 points!!!! 1. Imagine you are a screenplay writer. Discuss some possible activities or techniques you
atroni [7]

Answer:

One angle

Explanation:

I have seen several scripts with various directions such as "Close on" "from another angle", etc. And other scripts without such notations. I have seen conflicting comments concerning this practice---Some producers I have contacted say they want this IN the "finished script" they get and others, feel, like I do, that camera angles and lighting and such are up to the director in the production phase. I have also read that Spec Scripts do not have such notations. So what should I include or not, in this respect, in a Spec Script.

5 0
4 years ago
Two fingers are assigned to six letters each. What fingers are they?
Lena [83]

Answer:

The left and right index finger

Explanation:

Left index finger: R, T, F, G, C, V

Right index finger: Y, U, H, J, B, N

8 0
3 years ago
The following program results in a compiler error. Why? int FindMin(int a, int b) { int min; if (a < b) { min = a; } else { m
Mila [183]

Answer:

The answer is "Variable min is defined in the "FindMin()" method, but is used in the main method".

Explanation:

Following are the correct code to the given question:

#include <iostream>//header file

using namespace std;

int FindMin(int a, int b) //defining a method FindMin that takes two integer parameters

{

   int min; //defining integer variable

   if (a < b) //use if to check a value less than b

   {

       min = a; //holding smallest value in min

   }

   else //defining else block

   {

       min = b;//holding smallest value in min

   }

   return min; //return min value

}

int main() //defining main method

{

   int x,y,min; //defining integer variable

   cin >> x; //input value

   cin >> y; //input value

   min = FindMin(x,y); //holding method return value in min variable

   cout<<"The smaller number is: "<<min<< endl; //print method value with message

   return 0;

}

Output:

Please find the attached file.

In the code, a method "FindMin" is defined that takes two integer parameters "a,b" and inside the method, an integer variable "min" is declared that uses a conditional statement that checks the smallest value that store in the min variable and return its value.

In the main method, three integer variable is declared in which two is used for hold value from user-end pass into the method and store its return value in min variable and print value with the message.

7 0
3 years ago
(1) Nolan attempted to open a Word document that contains a macro and received a security warning stating, "Macros have been dis
Julli [10]

Answer:

1. Check where the file originates from, and if it is a trusted source or his own document, click Enable Content.

2. photo Album feature

3. Outer Join

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Smartphones can have virtual keyboards or physical keyboards. What are 3 advantages and disadvantages to each one?
    13·1 answer
  • Grace whistles while tickling Camille with a feather. Eventually, Camille starts to squirm and giggle every time Grace whistles,
    10·1 answer
  • Windows XPProfessional and Windows Vista Both have same devicedrivers.<br> True<br> False
    5·1 answer
  • Computers can think for themselves<br><br> True<br><br> False
    6·2 answers
  • Are Most job applications are online
    9·1 answer
  • What is the definition of trouble shooting.
    12·1 answer
  • The Monte Carlo method is commonly used to approximate areas or volumes of shapes. In this problem, we will use Monte Carlo to f
    12·1 answer
  • The Internet is written in a "language" called
    13·2 answers
  • UPS or FedEx plays what role in the supply?
    9·1 answer
  • HELP ME ILL GIVE BRAINLY Input 50 numbers and then output the average of the negative numbers only. Write in pseudocode!
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!