Baking a Bread

A bakery prepares bread by following a sequence of operations, as listed in the table. All the operations should be performed to make a bread. The bakery prepares two types bread : White and Sweet bread. It prepares bread in two different sizes : single and double size. Further, breads are baked either by  a semi-automation  process ( that is, a few operations will be done by using machines and then the remaining operations done manually) or by an automation process (using machines for all the operations).
The following table details the time taken by the machine in performing the different operations involved in baking a single size  bread using machines. For Eg., the time taken to make a single size, white bread using machine, is 2 hrs 58 minutes and 2 seconds.  The time taken by the machine to prepare a double size bread , will be  50%  more of the time taken to prepare the single size bread using machines. For eg., if ‘primary kneading’ for a single size white bread requires 15 minutes, then, for the double size white bread, ‘primary kneading’ requires 22.5 minutes (22 minutes 30 seconds)
 If baking is done by semi-automation process, use the machine till the ‘loaf-shaping cycle’ . Given the type of bread, size and type of baking, write an algorithm and the subsequent ‘C’ code to compute and display the time taken by the machine to prepare the bread.
Operation
White Bread
Sweet Bread
Primary Kneading
15 mins
20 mins
Primary rising
60 mins
60 mins
Secondary Kneading
18 mins
33 mins
Secondary rising
20 mins
30 mins
Loaf shaping
2 seconds
2 seconds
Final rising
75 mins
75 mins
Baking
45 mins
35 mins
Cooling
30 mins
30 mins
Input Format
First line contains the bread type (‘w’ or  ‘s’)
Next line contains the size of the loaf (‘1’ for single and ‘2’ for double)
Next line contains the type of baking (‘s’ for semi-automatic and ‘a’ for automatic)
Output Format
Print the duration in seconds, during which the machine is used .
Input:
First line contains the bread type (‘w’ or  ‘s’)
Next line contains the size of the loaf (‘1’ for single and ‘2’ for double)
Next line contains the type of baking (‘s’ for semi-automatic and ‘a’ for automatic)

Processing

#include<stdio.h>
int main()
{
    char type,size,bt;
    int t;
   switch(type)
   {
        case('w'):
        {
           t=263*60+2;
           if(bt=='s')
           t=113*60+2;
           if(size=='2')
            t=t*1.5;
            break;
        }
       case('s'):
       {
            t=283*60+2;
           if(bt=='s')
           t=143*60+2;
           if(size=='2')
           t=t*1.5;
       }
    }
   return 0;
}
Output:
The duration in seconds, during which the machine is used .
Program:
 #include<stdio.h>
int main()
{
    char type,size,bt;
    int t;
    scanf("%c",&type);
    scanf("%c",&size);
    scanf("%c",&bt);
    switch(type)
    {
        case('w'):
        {
            t=263*60+2;
            if(bt=='s')
            t=113*60+2;
            if(size=='2')
            t=t*1.5;
            break;
        }
        case('s'):
        {
            t=283*60+2;
            if(bt=='s')
            t=143*60+2;
            if(size=='2')
            t=t*1.5;
        }
    }
    printf("%d",t);
    return 0;
}
Pseudocode:
Step1: Enter the data
Step2:Make a switch case depending on type of bread
Step3:Calculate time depending on automatic or semi-automatic machine and size of bread
Step4:Print the time in seconds
Step5:End


No comments:

Post a Comment

Bonus Practice Problems(GMT To IST)

IST (Indian Standard Time) is 5 hours 30 minutes ahead of GMT(Greenwich Mean Time). Develop an algorithm and write the Python code to find...