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
PilotLPTM [1.2K]
3 years ago
15

Use a while loop to repeatedly take input from the user and calculate a sum. The user will only be allowed to type in numbers, b

ut remember the input function returns strings (so you will need to convert them with the built-in int function). If the user inputs the value -999, then the program should stop and print out the sum of all the numbers entered.
Computers and Technology
1 answer:
aev [14]3 years ago
3 0

Answer and Explanation:

#take input from user

n = int(input("Enter any number: "))

#sum variable to store sum

sum=0

#condition to exit from loop

while n!=-999:

   #adding entered number in sum variable

  sum=sum+n

  #take input from user

  n = int(input("Enter any number : "))

#print the sum  

print("sum =",sum)

output:

Enter any number: 10

Enter any number : 100

Enter any number : -999

sum = 110

You might be interested in
How are procedural and object-oriented programming approaches similar?
masya89 [10]

Answer:

A. Both approaches are used when writing programs.

Explanation:

Procedural programming (PP), also known as inline programming takes a top-down approach. It is about writing a list of instructions to tell the computer what to do step by step. It relies on procedures or routines. Object-oriented programming (OOP) is about encapsulating data and behavior into objects.

Hope this helps....

Have a nice day!!!!

4 0
3 years ago
Write a program to prepare the monthly charge account statement for a customer of CS CARD International, a credit card company.
WITCHER [35]

Answer:

import java.util.*;

import java.text.*;

class CreditCardBill

{

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in);

NumberFormat defaultFormat = NumberFormat.getCurrencyInstance(Locale.US);

System.out.println("CS Card International Statement");

System.out.println("===============================");

System.out.print("Previous Balance: $");

double prevBalance = sc.nextDouble();

System.out.print("Additional Charges: $");

double addCharges = sc.nextDouble();

double interest;

if(prevBalance == 0)

interest = 0;

else

interest = (prevBalance + addCharges) * 0.02;

System.out.println("Interest: "+defaultFormat.format(interest));

double newBalance = prevBalance + addCharges + interest;

System.out.println("New Balance: "+defaultFormat.format(newBalance));

double minPayment;

if(newBalance < 50)

minPayment = newBalance;

else if(newBalance <= 300)

minPayment = 50.00;

else

minPayment = newBalance * 0.2;

System.out.println("Minimum Payment: "+defaultFormat.format(minPayment));

}

}

5 0
3 years ago
Which of the following should NOT be done to keep people from slipping on floors?
irina [24]

you should not leave them to air dry

5 0
3 years ago
Which of the following is not an objective of Cloud design ?
ICE Princess25 [194]

A is the correct answer
3 0
3 years ago
20 POINTS- <br> can someone help with this?
Elis [28]

Answer:

large storage= data warehouse

data from daily= world wide

data storaage= transactional

online data= relational

I rlly don't know I'm kinda guessing here for don't take my word to heart it's been a bit since I've learned this

4 0
3 years ago
Other questions:
  • After you use the fill handle to copy cell contents, the quick copy options button appears, which can be used to fill the cells
    5·1 answer
  • A 5.5 g sample of a substance contains only carbon and oxygen. Carbon makes up 35% of the mass of the substance. The rest is mad
    8·1 answer
  • In what order are ribbons organized? From Microsoft Word
    7·1 answer
  • which field in the contact form is used to control the order in which contacts are displayed in the current view
    15·1 answer
  • Write qbasic code for given pattern<br><br>NEPAL<br>. EPA<br>. P​
    12·1 answer
  • Would 2 bits be enough to create a special code for each english vowel
    12·1 answer
  • What is the output of the following program?
    5·1 answer
  • 1.
    15·1 answer
  • Write a 200 word essay about how a computer is made.<br><br>Good luck.​
    9·1 answer
  • Rr lyrae stars pulsate, but with shorter periods and lower luminosities than cepheids. true false
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!