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
According to social penetration theory, the __________ dimension concerns the number of topics disclosed whereas the __________
dimulka [17.4K]
I am definitely sure that complete statement looks like this: According to social penetration theory, the breadth dimension concerns the number of topics disclosed whereas the depth dimension concerns the level of detail in topics disclosed. <span>Social penetration theory explains the differences between various levels of </span><span>interpersonal communication</span> in relation to the depth of interpersonal relationships.
7 0
2 years ago
Write a program that deliberately contains an endless or infinite while loop. The loop should generate multiplication questions
Westkost [7]

Answer:

The Java code is given below with appropriate variable names for better understanding

Explanation:

import java.util.Random;

import java.util.Scanner;

public class MultiplicationQuestions {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       Random rand = new Random();

       int n1, n2, result, total = 0, correct = 0;

       char ch = 'y';

       while(ch == 'y'){

           n1 = 1 + rand.nextInt(9);

           n2 = 1 + rand.nextInt(9);

           System.out.print("What is "+n1+" * "+n2+" ? ");

           result = scan.nextInt();

           if(result==n1*n2){

               System.out.println("Correct. Nice work!");

               correct++;

           }

           else{

               System.out.println("Incorrect. The product is "+(n1*n2));

           }

           System.out.print("Want more questions y or n ? ");

           ch = scan.next().charAt(0);

           total++;

       }

       System.out.println("You scored "+correct+" out of "+total);

   }

}

3 0
3 years ago
From where do we get information or knowledge? Explain.
Tems11 [23]

Answer:

the explanations is down here,

Explanation:

Information

Data reaches a more complex level and becomes information by integrating them to a context. Information provides expertise about facts or persons. Example of information: The information about a date of birth still has very little value when it is unknown to which person it belongs. By adding more information like the name, the linked information creates knowledge about a person.

Knowledge

Knowledge thus describes the collected information that is available about a particular fact or a person. The knowledge of this situation makes it possible to make informed decisions and solve problems. Thus, knowledge influences the thinking and actions of people. Machines can also make decisions based on new knowledge generated by information. In order to gain knowledge, it is necessary to process information.

7 0
3 years ago
Read 2 more answers
Which is true about TCP and UDP? Choose two answers.
vichka [17]

Answer:

TCP is a connection-oriented protocol

UDP does not acknowledge a receipt of data

Explanation:

TCP (Transmission Control Protocol) is a protocol to transfer data, this is one of the most important protocols on the entire internet, this method was implemented from the beginning of the network.

UDP (User Datagram Protocol) this is a protocol faster than TCP because this method doesn't establish a connection to sent data, in this case, always sent data, but TCP is more secure than UDP, and for that UDP is used to transfer music or videos, and TCP websites and database.

UDP doesn't need acknowledgment is done by UDP, is only concerned with speed.

7 0
3 years ago
Until 2015, each new Roblox user automatically had one friend. What was he called?
RUDIKE [14]

Until 2015, each new Roblox user automatically had one friend and the friend was called Builderman

Builderman is the friend that is provided automatically for all users until 2015

<h2>Further Explanation</h2>

The builderman welcomes each new Roblox user, send a message to them and automatically follows every user until when it was discontinued in 2014. The role of the Builderman was to introduce the game experience to each new Roblox user.

Roblox is an online game and serves as a platform where users can also create their own games. Roblox gives its users the platform to design their own games and allow its user to different kinds of games that are created by other users on the platform

Roblox hosts numerous games designed by its users and virtual worlds which covers different genres, such as traditional racing, obstacle courses and many more.

Roblox has millions of users worldwide, its monthly active users are over 100million. Roblox also allows its users to create virtual items for sale. This also implies, its users can create virtual items and sell them for other users

Roblox was founded by David Baszucki and Erik Cassel; it was released on September 1, 2006. It is a platform that allows single-player and multiplayer.

LEARN MORE:

  • Until 2015, each new Roblox user automatically had one friend. What was he called?  brainly.com/question/12694552
  • What is the programming language of Roblox called?  brainly.com/question/13166316

KEYWORDS:

  • roblox
  • builderman
  • friend
  • message
  • automatically
  • david baszucki
  • erik cassel
6 0
3 years ago
Read 2 more answers
Other questions:
  • The_provides access to the internet may also be internal​
    9·1 answer
  • When you align or size a group of selected controls, the changes are made relative to the
    14·1 answer
  • A coworker asks your opinion about how to minimize ActiveX attacks while she browses the Internet using Internet Explorer. The c
    14·1 answer
  • Each device attached to your computer comes with a special program called a(n ________ that enables the device and operating sys
    15·1 answer
  • A production house needs an operating system that captures saves and generates information within a specific time. Which type of
    11·1 answer
  • Where on the internet can you find a site that will allow you to tour bill gates mansion
    8·2 answers
  • Assume the availability of a function named oneMore. This function receives an integer and returns one more than its parameter.
    14·1 answer
  • Help
    7·1 answer
  • It is a minor cereal of importance only in West Africa where it is eaten in place of rice during during famines. Used for salads
    10·1 answer
  • Please define processor​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!