Hello, can someone helps me solve this (From Problem Solving and Program Design
ID: 3590710 • Letter: H
Question
Hello, can someone helps me solve this (From Problem Solving and Program Design in C BOOK)
Review Questions 229 9. 20.00 (first condition is met) 10. 40.00, the one in 10 11, when grade is Failed, no points earned when grade is B: Passed, points earned 3 when grade is b The switch statement is skipped so the output printed depends on the previous value of points (which may be garbage) 12. A nested if statement is on the left, a sequence of if statements is on t 13. a. 1 right. On the left x becomes 2; on the right x becomes 4 b. no C. 1(1 “ (308 10 >= 0) && (308 10 "): scanf("%lf", &temp; ) ; if (temp >32.0) not freezing) ice forming) era else 3. Write a multiple-alternative if statement to display a message indicating the educational level of a student based on the student's number of years of school ing (0, none; 1-5, elementary school; 6-8, middle school, 9-12, high school. and more than 12, college). Print a message to indicate bad data as well 4. Write a switch statement to select an operation based on the value of inven- tory. Increment total_paper by paper_order if inventory is 'B' or 'c' increment total-ribbon by ribbon-order if inventory is . E', 'F., or-D. increment total-label by label-order if inventory is 'A' or "X". Do noth ing if inventory is . M. . Display an error message if the value of inventory s not one of these eight letters 5. Write an if statement that displays an acceptance message for an astronaut candidate if the person's weight is between the values of opt_min and opt_maxExplanation / Answer
3. if(n==0) //n=no.of years of schooling
printf("education level is none ");
else if(n>=1&&n<=5) //checking n range
printf("education level is elementary school ");
else if(n>=6&&n<=8) //checking n range
printf("education level is middle school ");
else if(n>=9&&n<=12) //checking n range
printf("education level is high school ");
else if(n>12) //checking n range
printf("college");
else
printf("bad data");
4. switch(expression)
{
case 'B': total_paper++; //incrementing total_paper by paper_order
case 'C': total_paper++; //incrementing total_paper by paper_order
case 'E': total_ribbon++; //incrementing total_ribbon by ribbon_order
case 'F': total_ribbon++; //incrementing total_ribbon by ribbon_order
case 'D': total_ribbon++; //incrementing total_ribbon by ribbon_order
case 'A': total_label++; //incrementing total_label by label_order
case 'X': total_label++; //incrementing total_label by label_order
default: exit (0); //doing nothing
}
5.if(cw>=opt_min&&cw<=opt_max) //here cw is termed as candidate's weight
printf("accept"); //acceptance
else
printf("reject"); //rejection
//the below code is to check the range of person's age
if(pa>=age_min&&pa<=age_max)
printf("accept"); //acceptance
else
printf("reject"); //rejection
6. if(age>59) //checking age by relational operator
{
if(sts=='W')
printf("working senior");
else
printf("retired senior");
}
if(age>20) //checking if the age is greater than or not
{
printf("adult");
}
if(age>12) //checking whether he is teen or child
printf("Teen");
else
printf("Child");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.