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
emmainna [20.7K]
2 years ago
11

Write a program that declares and initializes a variable representing the weight in milligrams from the keyboard. The program di

splays the equivalent weight in kilograms, grams, and milligrams. For example, 1050042 milligrams are equivalent to 1 kilogram, 50 grams, and 42 milligrams.
Computers and Technology
1 answer:
Burka [1]2 years ago
3 0

Answer:

weight = int(input("Enter weight in milligrams: "))

kilograms = int(weight / 1000000)

grams = int((weight - (kilograms * 1000000)) / 1000)

milligrams = weight - ((kilograms * 1000000) + (grams * 1000))

print("{} milligrams are equivalent to {} kilogram(s), {} gram(s), and {} milligram(s)".format(weight, kilograms, grams, milligrams))

Explanation:

*The code is in Python.

Ask the user to enter the weight and set it to the variable weight

Calculate the kilograms, divide the weight by 1000000 and cast the result to the int (If the weight is 1050042, kilograms would be 1050042/1000000 = 1)

Calculate the grams, subtract the kilograms from the weight, divide it by 1000 and cast the result to the int (If the weight is 1050042, grams would be int((1050042 - (1 * 1000000)) / 1000) = 50)

Calculate the milligrams, subtract the kilograms and grams from the weight (If the weight is 1050042, milligrams would be 1050042 - ((1 * 1000000) + (50 * 1000)) = 42)

Print the weight, kilograms, grams, and milligrams in the required format

You might be interested in
___________ is related to mass, but also includes the gravitational pull of the Earth.
anygoal [31]
Earth's gravity comes from all its mass. All its mass makes a combined gravitational pull on all the mass in your body. That's what gives you weight. And if you were on a planet with less mass than Earth, you would weigh less than you do here. So weight is the answer
4 0
3 years ago
Which term describes the process by which light passes through an object or a medium.
Licemer1 [7]
For anyone reading this in the future, the correct answer is transmission. I just took the quiz 
5 0
3 years ago
Read 2 more answers
Write a program that reads three numbers and prints "increasing" if they are in increasing order, "decreasing" if they are in de
Lemur [1.5K]
You could assign values to variables and break it up into if else-if else statements.

<span>Pseudocode:</span>

if a < b and b < c:
    print("increasing")

else if a > b and b > c:
    print("decreasing")

else:
    print("neither")

Hope this helps.
7 0
3 years ago
What is the average time a caller waits for an operator to answer?
kaheart [24]
3-4 minutes is about right is say
7 0
3 years ago
The RAM memory of a computer contains the volatile memory, which includes
lara31 [8.8K]

The RAM memory of a computer contains the volatile memory, which includes; Websites recently visited

<h3>Random Access Memory(RAM)</h3>

Random access memory (RAM) is defined as a computer's short-term memory that it utilizes to handle all active tasks and applications.

Now, no single program, file, game, or stream would work without a RAM. Thus, RAM is a temporary storage that goes away when we shut down the computer.

Examples of things that RAM store from the options given is only websites visited recently.

Read more about Random Access Memory at; brainly.com/question/86807

3 0
2 years ago
Other questions:
  • When desktop publishing software can interact with another software program, the two are said to
    6·1 answer
  • ________ sets up a point-to-point connection between two computer systems over an Internet Protocol (IP) network. A. Point-to-Po
    15·1 answer
  • In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sid
    10·1 answer
  • Tell me the shortcut keys used in Ms PowerPoint ?​
    6·2 answers
  • You can leave out the ____ statements in a switch structure.
    15·1 answer
  • This was not a "true" operating system, but rather an operating environment.
    5·1 answer
  • Which diagram is used as a popular technique for investigating causes and effects? 1. Cause and effect 2. Fishbone/lshikawa 3. R
    13·1 answer
  • What is computer generation.<br>name that generations ​
    9·2 answers
  • Module 1 and 2 Coding Guided Notes Fill in your answers to each response as you read through the lesson pages in the coding cour
    11·2 answers
  • A financially stable person is able to:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!