In: Computer Science
C++ prgram:
The heating system in a school should be switched on if the average temperature is less than 17 degrees Celsius. The average temperature is found from the temperatures in the Art, English and Music departments. You are required to write a program that allows the user to input 3 temperatures. The program calculates and displays the average temperature and then displays "heating should be on " or " heating should be off" as appropriate.
draw a flowchart for the solution
C ++
#include <iostream>
using namespace std;
int main()
{
//varaibales declaration
int num1,num2,num3;
float temp = 0;
//prints the statement
cout<<"Enter Art Temperature: ";
//reads the input
cin>>num1;
cout<<"Enter English Temperature: ";
//reads the input
cin>>num2;
cout<<"Enter Music Departments Temperature: ";
//reads the input
cin>>num3;
//calculates the average
temp = num1+num2+num3/3;
//checks the conditon if average is less than 17 if block is
executed
if(temp<17)
{
//prints the statement
cout<<"heating should be on";
}
//when if block fails else block is executed
else
{
//prints the statement
cout<<"heating should be off";
}
return 0;
}
OUTPUT
FLOW CHART
THUMBS UP