A dietitian wants a way for clients to track calorics in fru


A dietitian wants a way for clients to track caloric\'s in fruits consumed pet day. Write a script that will prompt the user to select one of the fruits shown in the table below. After selecting a fruit the user should be asked it quantity consumed per day. Based on the caloric amounts in the table, print out the amount of calories consumed for the fruit selected your script should use the menu switch-case and fprintf functions.

Solution

fprintf(\'1 for Apple, 2 for Banana, 3 for Nectarine, 4 for Plum, \');
fprintf(\'5 for Mango\ \');
chose = input(\'Enter the fruit consumed: \');

quantity = input(\'Enter total quantity consumed: \');
fprintf(\'Total calories consumed: \');
switch( chose )
    case 1
        fprintf(\'%d\ \', quantity*81);
    case 2
        fprintf(\'%d\ \', quantity*105);
    case 3
        fprintf(\'%d\ \', quantity*67);
    case 4
        fprintf(\'%d\ \', quantity*36);
    case 5
        fprintf(\'%d\ \', quantity*135);
end

 A dietitian wants a way for clients to track caloric\'s in fruits consumed pet day. Write a script that will prompt the user to select one of the fruits shown

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site