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]
3 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]3 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
Which of these graphic elements combine text, illustrations, and color?
Likurg_2 [28]

Answer:

Send the picture.

Explanation:

8 0
3 years ago
Read 2 more answers
In order to identify the transmissions that belong to each VLAN, a switch will add a tag to Ethernet frames that identifies the
ira [324]

Answer:

True

Explanation:

Frame Tagging is a method Cisco developed to identify packets travelling through links also called VLAN Tagging.

8 0
3 years ago
What does median mean in the data?
QveST [7]

Answer:

What data? Also, if it's median wouldn't that be Mathematics? edit-im sorry im d-u-m-b i thought you meant there was numbers and data but you mean the meaning of median

the median in data is the middle number and if its an even number you add the two middles together and divide by two

again sorry

4 0
3 years ago
Read 2 more answers
Suppose you create a class Square to be a subclass of GeometricObject. Analyze the following code:
Lemur [1.5K]

Answer:

B. The program has a compile error because you attempted to invoke the GeometricObject class's constructor illegally.

Explanation:

To call a superclass constructor, the user must use super(). This is necessary unless default constructors are used. Also, it is vital to make sure if their are appropriate argument to be used while invoking the superclass constructor.

3 0
3 years ago
Two people can verify they are communicating with each other by using a ____________, which verifies each party's identity by be
photoshop1234 [79]

Answer:

b. Certificate Authority

Explanation:

Based on the information provided within the question it can be said that they are communicating with each other by using a certificate authority. This term refers to a company or organization that provides security verification by issuing both parties cryptographic keys which are specifically verified by the company in order to allow both parties to know exactly who they are communicating with.

5 0
3 years ago
Other questions:
  • 5 things that i learned about internet safty
    8·2 answers
  • Universal Containers is tracking the interviewer's ratings of candidate in Salesforce. They would like to easily link the Candid
    9·1 answer
  • Dylan, an interior designer, has sketched out a layout for a client's living room. He wants the client's approval of the layout
    11·2 answers
  • What is a feature of webmail
    13·1 answer
  • In cell M2, enter a formula using a nested IF function as follows to determine first if a student has already been elected to of
    12·1 answer
  • • > Four 240-pin DDR3 SDRAM DIMM sockets arranged in two channels • > Support for DDR3 1600+ MHz, DDR3 1333 MHz, and DDR3
    14·1 answer
  • The term structure, as it relates to programming, refers to the decisions you make to design your program to best meet its objec
    11·1 answer
  • Every windows service has the 3 start types what are those service types?
    15·1 answer
  • A project manager sets up a recurring invite for meetings using a web-based calendar app on a mobile device. What type of automa
    12·1 answer
  • What enforces the location in which an app can function by tracking the location of the mobile device?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!