Write a program to control a bread machine Allow the user to

Write a program to control a bread machine. Allow the user to input the type of bread as w for White and s for Sweet. Ask the user if the loaf size is double and if the baking is manual. The program should fail if the user inputs are invalid. The following table is a time chart for the machine used for each bread type. Print a statement for each step. If the loaf size is double, increase the baking time by 50 percent. If baking is manual, stop after the loaf-shaping cycle and instruct the user to remove the dough for manual baking. Use a function to print program instructions.

Time chart for making 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

Solution

// C++ program to control a bread machine.

#include <iostream>
#include <string.h>
#include <iomanip>      // std::setw


using namespace std;

void output(char loafShape, char baking, char typeBread)
{
    if (tolower(typeBread) == \'w\')
    {
        cout<< \"Primary kneading: 15 minute\" <<endl;
    }
    else if (tolower(typeBread) == \'s\')
    {
      cout<< \"Primary kneading: 20 minute\" <<endl;
    }
  
    cout<< \"Primary rising: 60 minutes \" <<endl;

    if (tolower(typeBread) == \'w\')
    {
        cout<< \"Secondary kneading: 18 minutes\" <<endl;
    }
    else if (tolower(typeBread) == \'s\')
    {
        cout<< \"Secondary kneading: 33 minutes\" <<endl;
    }


    if (tolower(typeBread) == \'w\')
    {
        cout<< \"Secondary rising: 20 minutes\" <<endl;
    }
    else if (tolower(typeBread) == \'s\')
    {
           cout<< \"Secondary rising: 30 minutes\" <<endl;
    }

    cout<< \"Loaf shaping: 2 seconds\" <<endl;



   if (tolower(baking) == \'y\')
   {
       cout <<\"You should remove the dough for manual baking.\" <<endl;
       return ;
   }


    cout<< \"Final rise for 75 mins\" <<endl;

    if (tolower(typeBread) == \'w\' && tolower(loafShape) == \'d\')
   {
       cout<< \"Baking: 67 minutes 30 seconds\" <<endl;
   }
   else if (tolower(typeBread) == \'w\' && tolower(loafShape) == \'s\')
   {
       cout<< \"Baking: 45 minutes\" <<endl;
   }
   else if (tolower(typeBread) == \'s\' && tolower(loafShape) == \'d\')
   {
       cout<< \"Baking: 52 minutes 30 seconds\" <<endl;
   }
   else if (tolower(typeBread) == \'s\' && tolower(loafShape) == \'s\')
   {
       cout<< \"Baking: 35 minutes\" <<endl;
   }


   cout<< \"Cooling: 30 minutes\" <<endl;
}


int main()
{
    char loafShape;
    char baking;
    char typeBread;

    cout<< \"Are you making white or sweet bread (w or s)? \";
    cin>> typeBread;
  

    cout<< \"Is this a single or double loaf (s or d)? \";
    cin>> loafShape;

    cout<< \"Are you going to bake manually (y or n)? \";
    cin>> baking;

    // input validation
    if(tolower(typeBread) != \'w\' && tolower(typeBread) != \'s\')
    {
        cout << \"Invalid Input\ \";
        return 0;
    }
    if(tolower(loafShape) != \'s\' && tolower(loafShape) != \'d\')
    {
        cout << \"Invalid Input\ \";
        return 0;
    }

    if(tolower(baking) != \'y\' && tolower(baking) != \'n\')
    {
        cout << \"Invalid Input\ \";
        return 0;
    }

    output(loafShape,baking,typeBread);
  

    //end
    return 0;
}


/*
output:

Are you making white or sweet bread (w or s)? s
Is this a single or double loaf (s or d)? d
Are you going to bake manually (y or n)? n
Primary kneading: 20 minute
Primary rising: 60 minutes
Secondary kneading: 33 minutes
Secondary rising: 30 minutes
Loaf shaping: 2 seconds
Final rise for 75 mins
Baking: 52 minutes 30 seconds
Cooling: 30 minutes


Are you making white or sweet bread (w or s)? w
Is this a single or double loaf (s or d)? s
Are you going to bake manually (y or n)? n
Primary kneading: 15 minute
Primary rising: 60 minutes
Secondary kneading: 18 minutes
Secondary rising: 20 minutes
Loaf shaping: 2 seconds
Final rise for 75 mins
Baking: 45 minutes
Cooling: 30 minutes


*/

Write a program to control a bread machine. Allow the user to input the type of bread as w for White and s for Sweet. Ask the user if the loaf size is double an
Write a program to control a bread machine. Allow the user to input the type of bread as w for White and s for Sweet. Ask the user if the loaf size is double an
Write a program to control a bread machine. Allow the user to input the type of bread as w for White and s for Sweet. Ask the user if the loaf size is double an

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site