C# Programming
Using the Example provided in this Week Folder,Create a Console application that solve the following problem:
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 Math, English and IT 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.
Submit your code here by pasting the code or by uploading the .cs file
Example provided:
/* Write a Program that fixes a LIMIT number as a constant
then that asks for the price
of an item and check if it's more or less than
the LIMIT, then display an appropriate message
*/
using System;
using static System.Console;
class CheckCredit
{
static void Main()
{
double price;
const double LIMIT = 5000;
Write("Enter price >> ");
price = Convert.ToDouble(ReadLine());
if(price > LIMIT)
WriteLine("You have exceeded the credit limit of ${0}", LIMIT);
else
WriteLine("Approved");
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace checkHeat
{
class Program
{
static void Main(string[] args)
{
float math,eng,it,avg;
Console.Write("Enter temerature of Math department : ");
math= float.Parse(Console.ReadLine());
Console.Write("Enter temerature of English department : ");
eng= float.Parse(Console.ReadLine());
Console.Write("Enter temerature of IT department : ");
it= float.Parse(Console.ReadLine());
avg=(math+eng+it)/3;
if(avg<17)
Console.Write("heating should be on");
else
Console.Write("heating should be off");
}
}
}
Get Answers For Free
Most questions answered within 1 hours.