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
4.17 LAB: Data File A comma separated value (.csv) file has been included to be used for this program. Each line contains two va
Andrej [43]

Answer:

import csv

def Csvreader(filename):

   with open("filename", "r") as file:

   content = file.csv_reader()

   list_content = list(content)

   file.close

   return list_content

Explanation:

This is a python description of the function that reads the csv file and converts it to a list, from the list, each item can accessed with its index and updated directly. Use this to draw the same conclusion for a java program.

7 0
3 years ago
Which type of communities handle recurring tasks in organization
12345 [234]
I think it's Standing committee
3 0
3 years ago
Your team has been asked to design a LAN for a very successful CPA firm with five departments in one building and a total of 560
ziro4ka [17]

Answer:

Please find in attachment.

Explanation:

The details in attachment are self explanatory.

Download docx
5 0
3 years ago
What contains programming statement written in VB?​
Alla [95]

Answer:

A statement in Visual Basic is a complete instruction. It can contain keywords, operators, variables, constants, and expressions. Each statement belongs to one of the following three categories: Declaration statements, which name a variable, constant, or procedure and can also specify a data type.

6 0
3 years ago
Plz help me I need this doneee
Vladimir79 [104]
Answer: I think it’s true
5 0
3 years ago
Other questions:
  • You need to control the number of people who can be in an oyster bar at the same time. Groups of people can always leave the bar
    12·1 answer
  • Tony Stark wants to build a 1000 meter high tower as quickly as possible. He has unlimited resources and an unlimited budget and
    8·2 answers
  • How can a user choose settings that will customize a presentation so that it is best to be played automatically at a kiosk rathe
    11·2 answers
  • All of these are required categories on a safety data sheet except
    14·2 answers
  • If you were investigating login issues on a Windows computer, which portion of the Event Viewer logs would be a good place to st
    7·1 answer
  • Your boss calls you in a panic. he said he just deleted three paragraphs and doesn t know how to bring them back. what do you te
    6·1 answer
  • A security administrator has replaced the firewall and notices a number of dropped connections. After looking at the data the se
    13·1 answer
  • 9.17 LAB: Acronyms An acronym is a word formed from the initial letters of words in a set phrase. Write a program whose input is
    6·1 answer
  • Who wants brainliest? First to answer gets it....
    12·2 answers
  • Help me. thank you very much
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!