Write a program that asks the user to enter an object’s mass, and then calculate
ID: 3666305 • Letter: W
Question
Write a program that asks the user to enter an object’s mass, and then calculates its weight in newtons. If the object weighs more than 500 newtons, display a message indicating that it is too heavy. If the object weighs less than 100 newtons, display a message indicating that it is too light. If the obtain is between 100 newtons and 500 newtons, display a message indicating that the object is within the desired weight specifications. Your programming challenge must contain the following:
A printed header stating the name of your conversion program. (Feel free to be creative)
Your program should also display a short written description of the program thats displayed for the user.
A python program that performs the actions mentioned above.
Your output must be formatted with two decimal places.
Explanation / Answer
/*program to print the weight of an object by taking mass of the object from the user
It has to display "It is too heavy" if the object weighs more then 500 newtons,it has to
display "It is too light" if the object weighs less than 100 and it has to display "It is within the desired weight specifications" if the weight lies between 100 and 500 newtons.*/
//program written in c language
//weight.c
#include<stdio.h>
#include<conio.h>
int main()
{
int mass,weight;
printf(" enter the mass of the object");
scanf("%d",&mass);
weight=mass*10;
if(weight>500)
printf(" It is too heavy");
else if(weight<100)
printf(" It is too light");
else if(weight<=500 && weight>=100)
printf(" It is within the desired weight specifications");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.