To convert weight measurements into letter category as follows: category weight
ID: 3563499 • Letter: T
Question
To convert weight measurements into letter category as follows:
category weight (pound)
A weight (=<)20.0
B 20.0 < weight (=<) 50.0
C 50.0 < weight (=<) 150.0
D 150.0 < weight
write a set of C++ statment that assign correct category value (A, B, C, or D ) to character variable CATEGORY based on the given value of weight . Assume that CATEGORY has been explicitly typed as a character variable. ( if you use other computer language such as Visual basic, Pascal, Fortran, etc., please specify which language you are using)
Explanation / Answer
#include<stdio.h>
int main()
{
int weight;
scanf("%d",&weight);
if(weight <= 20.0)
{
printf("A");
}
if(20 <= weight < 50.0)
{
printf("B");
}
if(50 < weight <= 150.0)
{
printf("C");
}
if(weight > 150)
{
printf("D");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.