Question

Create a GUI C#  application that solve the following problem: The heating system in a school should...

Create a GUI C#  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 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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "heatingSystem".This application contains a form with name "Form1.cs".Below are the files associated with form1.

1.Form1.cs[Design]

Heating System Enter Tempratures in Departments Arts English Music Calculate Average Temprature Exit

2.Form1.Designer.cs

namespace heatingSystem
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblArts = new System.Windows.Forms.Label();
this.txtArts = new System.Windows.Forms.TextBox();
this.btnAvgTemp = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.lblEnglish = new System.Windows.Forms.Label();
this.txtEnglish = new System.Windows.Forms.TextBox();
this.lblMusic = new System.Windows.Forms.Label();
this.txtMusic = new System.Windows.Forms.TextBox();
this.btnExit = new System.Windows.Forms.Button();
this.lblMessage = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// lblArts
//
this.lblArts.AutoSize = true;
this.lblArts.Location = new System.Drawing.Point(27, 32);
this.lblArts.Name = "lblArts";
this.lblArts.Size = new System.Drawing.Size(25, 13);
this.lblArts.TabIndex = 0;
this.lblArts.Text = "Arts";
//
// txtArts
//
this.txtArts.Location = new System.Drawing.Point(110, 29);
this.txtArts.Name = "txtArts";
this.txtArts.Size = new System.Drawing.Size(100, 20);
this.txtArts.TabIndex = 1;
//
// btnAvgTemp
//
this.btnAvgTemp.Location = new System.Drawing.Point(42, 134);
this.btnAvgTemp.Name = "btnAvgTemp";
this.btnAvgTemp.Size = new System.Drawing.Size(120, 37);
this.btnAvgTemp.TabIndex = 2;
this.btnAvgTemp.Text = "Calculate Average Temprature";
this.btnAvgTemp.UseVisualStyleBackColor = true;
this.btnAvgTemp.Click += new System.EventHandler(this.btnAvgTemp_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lblMusic);
this.groupBox1.Controls.Add(this.txtMusic);
this.groupBox1.Controls.Add(this.lblEnglish);
this.groupBox1.Controls.Add(this.txtEnglish);
this.groupBox1.Controls.Add(this.lblArts);
this.groupBox1.Controls.Add(this.txtArts);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(245, 116);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Enter Tempratures in Departments";
//
// lblEnglish
//
this.lblEnglish.AutoSize = true;
this.lblEnglish.Location = new System.Drawing.Point(27, 58);
this.lblEnglish.Name = "lblEnglish";
this.lblEnglish.Size = new System.Drawing.Size(41, 13);
this.lblEnglish.TabIndex = 2;
this.lblEnglish.Text = "English";
//
// txtEnglish
//
this.txtEnglish.Location = new System.Drawing.Point(110, 55);
this.txtEnglish.Name = "txtEnglish";
this.txtEnglish.Size = new System.Drawing.Size(100, 20);
this.txtEnglish.TabIndex = 3;
//
// lblMusic
//
this.lblMusic.AutoSize = true;
this.lblMusic.Location = new System.Drawing.Point(27, 84);
this.lblMusic.Name = "lblMusic";
this.lblMusic.Size = new System.Drawing.Size(35, 13);
this.lblMusic.TabIndex = 4;
this.lblMusic.Text = "Music";
//
// txtMusic
//
this.txtMusic.Location = new System.Drawing.Point(110, 81);
this.txtMusic.Name = "txtMusic";
this.txtMusic.Size = new System.Drawing.Size(100, 20);
this.txtMusic.TabIndex = 5;
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(168, 134);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(72, 37);
this.btnExit.TabIndex = 4;
this.btnExit.Text = "E&xit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMessage.Location = new System.Drawing.Point(64, 200);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(0, 20);
this.lblMessage.TabIndex = 6;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(275, 262);
this.Controls.Add(this.lblMessage);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnAvgTemp);
this.Name = "Form1";
this.Text = "Heating System";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label lblArts;
private System.Windows.Forms.TextBox txtArts;
private System.Windows.Forms.Button btnAvgTemp;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label lblMusic;
private System.Windows.Forms.TextBox txtMusic;
private System.Windows.Forms.Label lblEnglish;
private System.Windows.Forms.TextBox txtEnglish;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Label lblMessage;
}
}

3.Form1.cs

//namespaces
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//application namespace
namespace heatingSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//display average button click
private void btnAvgTemp_Click(object sender, EventArgs e)
{
//taking tempratures entered by user
double artsTemp = double.Parse(txtArts.Text);
double englishTemp = double.Parse(txtEnglish.Text);
double musicTemp = double.Parse(txtMusic.Text);
//calculate average temprature
double averageTemp = (artsTemp + englishTemp + musicTemp) / 3;
//variable to store heating system state
string status = "";
//checking temprature
if(averageTemp < 17)
{
status = "on";//set status on
}
else
{
status = "off";//set status off
}
//display details
lblMessage.Text = "Average Temprature : " + averageTemp + Environment.NewLine + " heating should be " + status;
}
//Exit button click
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

Heating System Enter Tempratures in Departments Arts English Music Calculate Average Temprature Exit

Screen 2 :Screen showing heating system

Heating System Enter Tempratures in Departments Arts English 23 15 Music Calculate Average Temprature Exit Average Temprature

Screen 3 :

Heating System Enter Tempratures in Departments Arts 10 English 23 15 Music Calculate Average Temprature Exit Average Temprat

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Create a GUI C#  application that solve the following problem: The heating system in a school should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be...

    IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equiva-lent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit to Celsius depending on the user's choice. Some hints: Use JTextField and...

  • Astronomy helper Create an application that displays the following menu: select a planet 1. Mercury 2....

    Astronomy helper Create an application that displays the following menu: select a planet 1. Mercury 2. Venus 3. Earth 4. Mars 5. exit the program Enter your selection. When the user selects a planet from the menu, the program should display data about the planet's average distance from the sun, the planet's surface temperature. Use the following data in your program: Mercury Average distance from the sun ---------- 57.9 million kilometers Mass---------------3.31 x 10^23kg surface temperature------------ -173 to 430 degrees...

  • In Java. Write a GUI contact list application. The program should allow you to input names...

    In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...

  • IN JAVA…PLEASE comment the code thoroughly so I can understand the thought process. Write a GUI...

    IN JAVA…PLEASE comment the code thoroughly so I can understand the thought process. Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • You will be designing and creating a Java GUI-based course application. Create a “Student” class. You...

    You will be designing and creating a Java GUI-based course application. Create a “Student” class. You need to have at least 3 instance variables (student characteristics like name,…), at least 2 constructors (1 should be a no-arg constructor), set and get methods. Create a “Course” class that consists of 2 instance variables: the course name and an array of Students (using your Student class). Design and create a JavaFX-based GUI interface that allows you to : INPUT information for Course...

  • Travel Expenses Create a GUI in C# Visual Studios application that calculates and displays the total...

    Travel Expenses Create a GUI in C# Visual Studios application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of taxi charges, if any...

  • C# Visual Studios Create a GUI application that prompts users to enter a ten (10) digit...

    C# Visual Studios Create a GUI application that prompts users to enter a ten (10) digit phone number, with hyphens and parentheses included – this input should be validated as a phone number adhering to the (XXX)-XXX-XXXX format. Should the user input an incorrect format, an error message should print to screen and your phone number textbox should be highlighted in red. Should an appropriately formatted phone number be entered, an acceptance message should printed to screen and your phone...

  • Create an application that calculates the total cost of a hospital stay. The application should accept...

    Create an application that calculates the total cost of a hospital stay. The application should accept the following input: the number of days spent in the hospital (as an integer), the amount of medication charges, the amount of surgical charges, the amount of lab fees, and the amount of physical rehabilitation charges. The hospital charges $350 per day. Create the following functions. A. CalcStayCharges- Calculates and returns the base charges for the hospital stay. This is computed as $350 times...

  • Create an application that tracks electric motors in a manufacturing plant. The application should have a...

    Create an application that tracks electric motors in a manufacturing plant. The application should have a Motor class with the following properties: MotorId: Five digit string, such as "02340" Description: String RPM: Double, values in the range 10 to 10000 Voltage: Double, values in the range 1 to 500 Status: String, three characters The Status values are: ON: Motor is online and running OFF: Motor is online but not running MNT: Motor is undergoing maintenance and cleaning NA: Motor isn't...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT