![]() |
CS411 ASSIGNMENT NO. 2 FALL 2022 |
KINDLY, DON’T COPY PASTE
CS411 ASSIGNMENT NO. 2 FALL 2022 || 100% RIGHT SOLUTION || VISUAL PROGRAMMING || BY VuTech
Visit Website For More Solutions
www.vutechofficial.blogspot.com
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
kamranhameedvu@gmail.com
Please read all the instructions carefully
before attempting the assignment.
RULES FOR MARKING
It should be clear that your
assignment would not get any credit if:
- The assignment is
submitted after the due date.
- The submitted assignment
does not open or file is corrupt.
- You have not used your own
student ID in code files and GIF file.
- Student ID is not visible
in GIF file.
- Strict action will be taken if submitted solution is copied from any other student or from the internet.
Lectures:
·
Lectures 13 to 22 are covered in this assignment
NOTE No
assignment will be accepted after the due date
via email in any case (whether it is the case of load shedding
or internet malfunctioning etc.). Hence refrain from uploading assignment in
the last hour of deadline. It is recommended to upload solution file at least
two days before its closing date. If
you people find any mistake or confusion in assignment (Question statement),
please consult with your instructor before the deadline. After the deadline
no queries will be entertained in this regard. For any query, feel free to email
at: cs411@vu.edu.pk |
Output.GIF has been attached with this Assignment file. Please
observe this file carefully. Your program’s output must be like this output
file.
Submission
details: Following files must be
submitted in a single zip or rar file.
|
Problem Statement:
The body mass index (BMI) is a
measure that uses your height and weight to work out if your weight is healthy.
BMI takes into account natural variations in body shape, providing a calculated
value for a healthy weight range for a particular height.
If your BMI is:
² below
18.5 – you're in the underweight range
² between 18.5
and 24.9 – you're in the healthy weight range
² between 25 and
29.9 – you're in the overweight range
² 30 or
over – you're in the obese range
People who have overweight or obesity, compared to those with healthy weight, are at increased risk for many serious diseases and health conditions. These include:
- High blood pressure (hypertension).
- Type 2 diabetes.
- Coronary heart disease.
- Sleep apnoea and breathing problems.
- Many
types of cancer.
- Low quality of life.
- Mental illness such as clinical
depression, anxiety, and other mental disorders.
- Body pain and difficulty with physical
functioning.
Maintaining a healthy weight is important for overall health and can help you prevent and control many diseases and conditions.
Keep in view the above discussion, you are
required to create a C# WPF
application using Visual Studio that calculates the Body
Mass Index with the following functional requirements:
Application Interface:
- When the application starts, the following screen should be displayed as shown in sample output below:
- There should be your OWN VUID in RED color that should be visible at top left corner as shown in the sample output.
- There should be two labels of “Height” and “Weight” along with two “text boxes” visible at the center of the screen similar to as shown in the sample output.
- There should be a combo box button below the textbox of weight and it should contain two combo box items, “Standard” and “Metric” as shown in the sample output in .GIF file.
- After the combo box, there should be a button labeled as “CalculateBMI” and another button labeled as “Clear”, similar to as shown in the sample output.
- Below “CalculateBMI” button, there should be two labels, “Result” and “Comments” and in the horizontal space after these labels, there should be two hidden labels which will only be visible if the button “CalculateBMI” is clicked as shown in the sample output in .GIF file.
- There should be a text block having text “MY BMI Calculator” rotated with an angle of 8 degrees at the righter space after the text boxes of Height and Weight, similar to as shown in the sample output.
- The whole background should be colored of your own choice as shown in sample output. The buttons ”CalculateBMI” and “Clear” should have a background color of your own choice. The background color below your VUID should be different from the whole background color, as shown in the sample output.
- You have to use the all the appropriate properties like margin, padding, font sizes, colors, font weights etc to make a similar application as shown in the sample output.
Execution Requirements:
- Firstly, without entering any values in any text box, you have to click on the “CalculateBMI” button. So, on clicking the ”CalculateBMI” button, a message should be displayed having the text “please enter the height and weight”.
- Then you will enter the height as 71 inches and weight as 150 pounds and click “CalculateBMI” button. After clicking the button, the hidden labels should be visible with correct values and comments. (No other input values will be considered in any case, so be careful and use only the mentioned values)
- The Calculated BMI value should be rounded-off to only two fractional digits after the decimal.
- Then you will select the combobox item to “Metric” on combo box without changing the values, (using same values as height = 71 CM and weight = 150 KG). On changing the combobox item to “Metric”, the labels of the Height (inches) and Weight (Pounds) should be changed to “Height (CM)” and “Weight (Kg)” as shown in the sample output in .GIF file.
- Now, Click the “CalculateBMI” button again, the result and comments should change with correct BMI value and comments.
- From the Calculated BMI value, you have to use the appropriate comment as per the following table:
- Then you will click the “Clear” button. On clicking it, all the text boxes should be emptied and BMI value and BMI comments should be cleared and should be made hidden, same like they were hidden at the start of the application.
Formulas
for Calculating BMI:
- For BMI in Standard: Use the following formula in your application for calculating BMI in Standard (I.e. Height in inches and Weight in Pounds)
BMI_in_Standard = 703 x (weight / (height x height));
- For BMI in Metric: Use the following formula in your application for calculating BMI in Metric (I.e. Height in CM and Weight in KG)
BMI_in_Metric = 10000 x (weight / (height x height));
Important Note Regarding GIF:
Note: When you run your project,
start your .GIF recording only when your output window becomes visible (Do not
include any unnecessary part in .GIF file as it wastes time). Moreover, make
sure that your .GIF file should not be more than 10 to 15 seconds at maximum.
Best
of Luck!
SOLUTION
Program:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace BMICalculator
{
public partial class MainWindow : Window
{
// Initialize variables for height, weight, and units
double height = 0;
double weight = 0;
string units = "Standard";
public MainWindow()
{
InitializeComponent();
// Set background color of application
Background = new SolidColorBrush(Color.FromRgb(240, 240, 240));
// Set background color of header
header.Background = new SolidColorBrush(Color.FromRgb(200, 200, 200));
// Set font size and weight of labels and buttons
labelHeight.FontSize = 18;
labelWeight.FontSize = 18;
labelResult.FontSize = 18;
labelComments.FontSize = 18;
labelResult.FontWeight = FontWeights.Bold;
labelComments.FontWeight = FontWeights.Bold;
buttonCalculate.FontSize = 18;
buttonClear.FontSize = 18;
// Set padding for labels and buttons
labelHeight.Padding = new Thickness(10);
labelWeight.Padding = new Thickness(10);
labelResult.Padding = new Thickness(10);
labelComments.Padding = new Thickness(10);
buttonCalculate.Padding = new Thickness(10);
buttonClear.Padding = new Thickness(10);
// Set background color of buttons
buttonCalculate.Background = new SolidColorBrush(Color.FromRgb(0, 122, 204));
buttonClear.Background = new SolidColorBrush(Color.FromRgb(255, 128, 128));
}
private void buttonCalculate_Click(object sender, RoutedEventArgs e)
{
// Check if height and weight values have been entered
if (textBoxHeight.Text == "" || textBoxWeight.Text == "")
{
MessageBox.Show("Please enter the height and weight");
return;
}
// Get height and weight values
height = double.Parse(textBoxHeight.Text);
weight = double.Parse(textBoxWeight.Text);
// Calculate BMI based on units
double bmi = 0;
if (units == "Standard")
{
bmi = (weight * 703) / (height * height);
}
else if (units == "Metric")
{
bmi = weight / (height * height);
}
// Round BMI to two decimal places
bmi = Math.Round(bmi, 2);
// Display result and comments
labelResult.Content = "BMI: " + bmi;
labelResult.Visibility = Visibility.Visible;
if (bmi < 18.5)
{
labelComments.Content = "Underweight";
}
else if (bmi >= 18.5 && bmi <= 24.9)
{
labelComments.Content = "Healthy weight";
}
else if (bmi >= 25 && bmi <= 29.9)
{
labelComments.Content = "Overweight";
}
else if (bmi >= 30)
{
labelComments.Content = "Obese";
}
labelComments.Visibility = Visibility.Visible;
}
private void buttonClear_Click(object sender, RoutedEventArgs e)
{
// Clear all values and results
textBoxHeight.Text = "";
textBoxWeight.Text = "";
labelResult.Visibility = Visibility.Hidden;
labelComments.Visibility = Visibility.Hidden;
}
private void comboBoxUnits_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Update units and labels based on combo box selection
units = comboBoxUnits.SelectedItem.ToString();
if (units == "Standard")
{
labelHeight.Content = "Height (inches)";
labelWeight.Content = "Weight (pounds)";
}
else if (units == "Metric")
{
labelHeight.Content = "Height (cm)";
labelWeight.Content = "Weight (kg)";
}
}
}
}
OUTPUT
Visit Website For More Solutions
www.vutechofficial.blogspot.com
KINDLY, DON’T COPY PASTE
SUBSCRIBE, SHARE, LIKE AND COMMENTS FOR MORE UPDATES
SEND WHATSAPP OR E-MAIL FOR ANY QUERY
0325-6644800
kamranhameedvu@gmail.com