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
A search engine attempts to catalog every Web page by topic through the use of a ____
-BARSIC- [3]
<span>A search engine attempts to catalog every Web page by topic through the use of a spider (web crawlers). </span>
8 0
3 years ago
The waterfall model and spiral model are variations of SDLC. Do some research to find out what they are and explain how these mo
Radda [10]

Waterfall model and spiral model are used in software development life cycle or SDLC. Any software development process follows one of these models depending on the type of software and the requirements of the customer.

Waterfall model

This model is called as sequential model since it works in stages. The output of first stage becomes the input of the second stage.

The errors of the first stage can be rectified only when it is completed. This is time consuming and makes the process lengthy. Stage 1 is completed before stage 2 begins.

The six stages involved in waterfall model are Requirement Gathering and analysis, System Design, Implementation, Integration and Testing, Deployment of system, and Maintenance.

Spiral model

This model is implemented in iterations. It is also called evolutionary model.  

Initially a prototype of the system is prepared. Then, it is followed by development of small parts of the system.

These smaller parts are then assembled to produce the final system.

The four stages which form the spiral model are Identification, Design, Development and Evaluation and Risk Analysis.

The differences between the two models are summarized below.

1. Waterfall model works in linear method. Spiral model follows evolutionary method.

2. Errors and risks are discovered/ rectified after the stage is over. Errors and risks are discovered/ rectified earlier.

3. Waterfall model is suitable for small projects. Spiral model is suitable for large projects.

4. Requirements identification and planning is the initial stage in the waterfall model. Requirements identification and planning is done when needed, in the spiral model.

5. Waterfall model allows little to no flexibility in the system. Spiral model allows flexibility in the system.

6. Low flexibility makes the waterfall model more risky. High flexibility makes the spiral model less risky.

7. Waterfall model, overall, takes less time since requirements are clear. Spiral model is implemented when the requirements of the system are not clear and become clear through prototypes.

8 0
3 years ago
Q4. Write down the JavaScript statements to perform the following tasks.
goldenfox [79]

Answer:

Explanation:

In Javascript, you can accept an input value by using the prompt() function and saving the input into a variable. In the following lines of code, I have declared the three variables at the beginning and then prompted the user to enter a value for each and saved the values in the correct variables. In Javascript length is a keyword so I used len instead.

let base, height, len;

base = prompt("Enter Base value: ");

height = prompt("Enter Height value: ");

len = prompt("Enter Length value: ");

5 0
2 years ago
According to a case study in one of our weekly chapter reading, nearly..................... percent of all employees send work e
ozzi

Answer:

A.80, and uncontrolled

3 0
3 years ago
Read 2 more answers
__________ delivers a comprehensive and accurate graphical overview of key performance indicators, often using a single screen.
Irina18 [472]
The answer is a digital dashboard.

In its simplest form, a digital dashboard or a business dashboard provides a graphical representation of KPIs, measures and metrics used by a company to monitor performance of departments, individuals, teams or the entire company. They track the progress of business objectives and make effective data driven decisions.



6 0
3 years ago
Other questions:
  • F we are reduced to a set of computer algorithms, how do we differentiate ourselves from our programming or our connectome? is i
    8·1 answer
  • Which of the following is NOT a web browser?<br> Safari<br> Chrome<br> Bing<br> Firefox
    8·2 answers
  • Why is a networked system a benefit?
    7·1 answer
  • Follow up, my brother is upset at me for stealing his robux, what should i do?
    11·2 answers
  • The computer has had far-reaching effects on our lives.how has the computer effected your life?
    8·1 answer
  • Greg wants to check the amount of requests his website receives. What test can he use?
    6·1 answer
  • Why it is not recommended to add sound effect on slide transition? Write at least two reasons.​
    6·1 answer
  • How do you use switch board in the office​
    6·1 answer
  • The code to perform a binary search is below. Match the variable name with what it holds.
    12·1 answer
  • By definition, what is the process of reducing security exposure and tightening security controls?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!