Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using c++ write a program for the toaster problem below. Please show your output

ID: 3722357 • Letter: U

Question

using c++ write a program for the toaster problem below. Please show your output screen

Project Description The oven will have four dials/selectors as listed below: • A Function selector: Toast, Broil, Warm, Bake (no need to set the time and the temperature when on Toast) • A temperature selector: used to set temp from 0 – 450 degree Fahrenheit • A time selector: used to set time from 0 to 60 minutes • A toast selector: light (sets time to 1 min.), mild (Sets time to 2 min.), dark (sets time to 3 min). Time is automatically set by the toaster selection. The user opens the oven door, pulls the oven tray out, places the food in the tray, pushes the try back in, closes the oven door then sets the dials (not all of them necessarily). Oven has a light indicator that goes on when oven is in use. When oven is done a bell rings and the light goes off.

Explanation / Answer

#include "stdafx.h"

#include <iostream>

#include <chrono>

#include <thread>

#include <string>

using namespace std;

int TempretureSelector()

{

int t;

while (true) {

cout << " Select a temperature between 0 to 450 degree Fahrenheit: ";

cin >> t;

if (t > 0 && t <= 450)

{

return t;

}

else {

cout << "Wrong input... Please try agin.";

}

}

}

int TimeSelectorSelector()

{

int t;

while (true) {

cout << " Select a time between 0 to 60 minutes : ";

cin >> t;

if (t > 0 && t <= 60)

{

return t;

}

else {

cout << "Wrong input... Please try agin.";

}

}

}

int ToastTypeSelector()

{

int n;

while (true)

{

cout << "Please select the type of toast: ";

cout << "1 for light ";

cout << "2 for mild ";

cout << "3 for dark ";

cin >> n;

if (n == 1 || n == 2 || n == 3)

{

return n;

}

else

{

cout << "Wrong input... Please try agin.";

}

}

}

void PerFormCooking(int temperature, int time, string opName)

{

int timeInSeconds = time * 60;

cout << opName + " is in progress.";

// lighting indicator after each 2 seconds

int indicatorTime = 2;

for (int i = 0; i < timeInSeconds; i = i + indicatorTime)

{

std::this_thread::sleep_for(std::chrono::milliseconds(indicatorTime * 1000));

cout << ".";

}

cout << " Operation Completed!!!";

// make operation complete sound

for (int i = 1; i < 5; i++)

{

cout << '';

std::this_thread::sleep_for(std::chrono::milliseconds(2 * 1000));

}

}

void ToastFunction()

{

int time = ToastTypeSelector();

PerFormCooking(200, time, "Toast");

}

void BroilFunction()

{

int temperature = TempretureSelector();

int time = TimeSelectorSelector();

PerFormCooking(temperature, time, "Boiling");

}

void WarmFunction()

{

int temperature = TempretureSelector();

int time = TimeSelectorSelector();

PerFormCooking(temperature, time, "Warming");

}

void BakeFunction()

{

int temperature = TempretureSelector();

int time = TimeSelectorSelector();

PerFormCooking(temperature, time, "Bake");

}

void SelectOperation()

{

int n;

cout << "Please select opearation: ";

cout << "1 for Toast ";

cout << "2 for Broil ";

cout << "3 for Warm ";

cout << "3 for Bake ";

cin >> n;

switch (n)

{

case 1:

ToastFunction();

break;

case 2:

BroilFunction();

break;

case 3:

WarmFunction();

break;

case 4:

BakeFunction();

break;

default:

cout << "Input is not correct...";

break;

}

}

int main()

{

SelectOperation();

return 0;

}