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
solmaris [256]
2 years ago
12

Write a calculator program that keeps track of a subtotal like real calculators do. Start by asking the user for an initial numb

er. Inside a loop, asks the user for a mathematical operation and a second number. Do the operation with the first number on the second number. Keep track of the result as a 'subtotal' to be used as the first number when going back to the top of the loop. When the user quits, print out the final result and quit the program. See output for an example for the behavior of the program. The operations should be at least
Computers and Technology
1 answer:
Taya2010 [7]2 years ago
8 0

Answer:

num1 = float(input("Enter the first number: "))

while True:

   print("Add, Subtract, Multiply, Divide, or Quit ?")

   choice = input("Your choice is: ")

   if choice == "Quit":

       break

   num2 = float(input("Enter the second number: "))

   if choice == "Add":

       num1 += + num2

       print("The subtotal is: " + str(num1))

   elif choice == "Subtract":

       num1 -= num2

       print("The subtotal is: " + str(num1))

   elif choice == "Multiply":

       num1 *= num2

       print("The subtotal is: " + str(num1))

   elif choice == "Divide":

       num1 /= num2

       print("The subtotal is: " + str(num1))

print("The final result is: " + str(num1))

Explanation:

Ask the user for the first number

Create a while loop that iterates until specified condition occurs inside the loop

Ask the user for the operation or quitting

If the user chooses quitting, stop the loop. Otherwise, get the second number, perform the operation and print the subtotal

When the loop is done, the user enters Quit, print the final value result

You might be interested in
What is the output of doublec= 12.0 / 5 Systemoutprintln (c)
artcher [175]

Answer:

The code will produce:-

2.4

Explanation:

In this code the result of the arithmetic operation is stored in the variable c.On evaluating the expression it divides 12.0 by 5 which results in 2.4 and it is stored in float variable c.Then it is printed on the screen using print statement.Since the c is double variable so the result will be a decimal number.

Hence the answer is 4.

6 0
3 years ago
Using recursion, write a program that asks a user to enter the starting coordinates (row, then column), the ending coordinates (
Luden [163]

Answer:

The program in Python is as follows

def Paths(row,col):

if row ==0 or col==0:

 return 1

return (Paths(row-1, col) + Paths(row, col-1))

row = int(input("Row: "))

col = int(input("Column: "))

print("Paths: ", Paths(row,col))

Explanation:

This defines the function

def Paths(row,col):

If row or column is 0, the function returns 1

<em> if row ==0 or col==0: </em>

<em>  return 1 </em>

This calls the function recursively, as long as row and col are greater than 1

<em> return (Paths(row-1, col) + Paths(row, col-1))</em>

The main begins here

This prompts the user for rows

row = int(input("Row: "))

This prompts the user for columns

col = int(input("Column: "))

This calls the Paths function and prints the number of paths

print("Paths: ", Paths(row,col))

4 0
2 years ago
Kiara is using her software's graphic formats to create a line graph. As she
Ad libitum [116K]

Correct the data she entered , and the software will adjust the graph -apex

5 0
3 years ago
Read 2 more answers
Anyone help me please​
MissTica

Answer:

1. True

2. False

3. True

4. False

5. True

6. True

7. False

4 0
3 years ago
Read 2 more answers
Damage to which portion of the limbic system results in loss of memory of recent events and difficulty committing anything new t
Vera_Pavlovna [14]

Answer:

Hippocampus.

Explanation:

There are two parts of the limbic system. They are the frontal part which is the amygdala and the posterior part which is the hippocampus.

The hippocampus is an extension of the temporal part  of the cerebral cortex which is a plastic-like structure that can be easily damaged by stimuli. It is packed with densed neurons and forms an S-shape at the extension of the temporal part.

It is responsible for learning and memory and damage to it can result to memory loss of recently learnt information.

8 0
2 years ago
Other questions:
  • How i can connect to internet automatically when i switch on my computer?
    8·1 answer
  • How can an individual find career data?
    13·1 answer
  • When a communication exchange that does not verify the identity of the endpoints of a communication and accepts any properly for
    10·1 answer
  • Programming challenge description: Write a program that, given two binary numbers represented as strings, prints their sum in bi
    6·1 answer
  • What is the meaning of Re:?
    12·2 answers
  • What is MS-Word? Write some versions of MS-Word.
    8·2 answers
  • Which type of boot authentciation is more secure?
    10·1 answer
  • Five uses of the operating system​
    10·2 answers
  • Why does this happen
    5·1 answer
  • What is technology?5points​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!