CS411 Assignment Solution with Code Fall 23 by GetReady

  

CS411 Assignment  Solution with Code Fall 23 by GetReady 



XANL CODE:


<Window x:Class="JUNAID_MALIK.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:JUNAID_MALIK "

        mc:Ignorable="d"

        Title="MainWindow" Height="699" Width="1003">

    <Grid HorizontalAlignment="Center" Width="979" Margin="0,0,0,-6">

        <Grid.RowDefinitions>

            <RowDefinition Height="216*"/>

            <RowDefinition/>

        </Grid.RowDefinitions>

        <Border BorderBrush="Black" BorderThickness="1" Margin="-22,-15,-24,510" Background="#FF7A45C1" IsEnabled="False">

            <TextBlock TextWrapping="Wrap" Background="#00000000" Foreground="White" FontSize="36" FontWeight="Bold" Margin="0,31,147,0" Height="91" VerticalAlignment="Top" HorizontalAlignment="Right" Width="787"><Run Text="JUNAID MALIK"/><Run Text=" : For Paid Cotact (03041659294)"/></TextBlock>

 

        </Border>

        <Canvas Background="Blue" Height="612" VerticalAlignment="Top" Margin="-22,109,-24,0" Grid.RowSpan="2">

            <Label x:Name="lblHeight" Content="Height (inches)" Canvas.Left="94" Canvas.Top="65" HorizontalAlignment="Left" VerticalAlignment="Center" Width="159" Height="35" FontSize="18" FontWeight="Bold"/>

            <Label x:Name="lblWeight" Content="Weight (pounds)" Canvas.Left="94" Canvas.Top="129" Width="159" Height="35" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18" FontWeight="Bold"/>

            <TextBox  x:Name="txtHeight" Canvas.Left="291" TextWrapping="Wrap" Text="" Canvas.Top="61" Width="230" Height="39" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" Margin="0,5,0,0"/>

            <TextBox  x:Name="txtWeight" Canvas.Left="291" TextWrapping="Wrap" Text="" Canvas.Top="129" Width="230" Height="39" HorizontalAlignment="Center" VerticalAlignment="Top"/>

            <ComboBox x:Name="UnitComboBox" SelectedIndex="1" Canvas.Left="291" Canvas.Top="212" HorizontalAlignment="Left" VerticalAlignment="Center" Width="230" Height="43" FontSize="18" SelectionChanged="UnitComboBox_SelectionChanged_1">

                <ComboBoxItem Content="Standard"/>

                <ComboBoxItem Content="Metric"/>

            </ComboBox>

            <Button Content="Calculate BMI" Canvas.Left="291" Canvas.Top="283" HorizontalAlignment="Left" VerticalAlignment="Top" Width="129" Height="57" Background="Green" Click="CalculateBMI_Click" FontSize="18" FontWeight="Bold"/>

            <Button Content="Clear" Canvas.Left="540" Canvas.Top="283" Width="92" Height="57" Background="Green" Click="Clear_Click" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>

            <Label Content="Result :" Canvas.Left="24" Canvas.Top="424" HorizontalAlignment="Left" VerticalAlignment="Top" Width="78" FontSize="18" FontWeight="Bold"/>

            <Label Content="Comments :" Canvas.Left="24" Canvas.Top="488" Width="113" FontSize="18" FontWeight="Bold" HorizontalAlignment="Left" VerticalAlignment="Center"/>

            <TextBlock Canvas.Left="724" TextWrapping="Wrap" Canvas.Top="116" FontSize="28" FontWeight="Bold" Height="124" Width="249" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="White" RenderTransformOrigin="0.5,0.5">

                <TextBlock.RenderTransform>

                    <TransformGroup>

                        <ScaleTransform/>

                        <SkewTransform/>

                        <RotateTransform Angle="33.623"/>

                        <TranslateTransform/>

                    </TransformGroup>

                </TextBlock.RenderTransform><Run Text=" My BMI "/><LineBreak/><Run Text="Calculator"/></TextBlock>

            <Label x:Name="ResultLabel" Canvas.Left="222" Canvas.Top="426" Height="82" Width="440" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="#FFD3E614" FontWeight="Bold"/>

            <Label x:Name="CommentsLabel" Canvas.Left="222" Canvas.Top="488" Height="71" Width="440" FontSize="20" Foreground="#FFD3E614" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Top"/>

        </Canvas>

 

    </Grid>

</Window>

 

 

 C# CODE:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Numerics;

using System.Security.Cryptography.X509Certificates;

using System.Security.Policy;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;

using System.Xml.Linq;

namespace JUNAID_MALIK

{

    public partial class MainWindow : Window

    {

        public MainWindow()

        {

            InitializeComponent();

        }

 

        private void btnCalculate_Click(object sender, RoutedEventArgs e)

        {

            if (string.IsNullOrEmpty(txtHeight.Text) || string.IsNullOrEmpty(txtWeight.Text))

            {

                MessageBox.Show("Please enter the height and weight", "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                return;

            }

 

            double height = double.Parse(txtHeight.Text);

            double weight = double.Parse(txtWeight.Text);

 

            double bmi = 0;

            if (cmbUnit.SelectedIndex == 0)

            {

                bmi = weight * 703 / (height * height);

            }

            else

            {

                bmi = weight / (height * height);

            }

 

            lblResultValue.Content = Math.Round(bmi, 2);

            lblResultValue.Visibility = Visibility.Visible;

            lblResult.Visibility = Visibility.Visible;

 

            if (bmi < 18.5)

            {

                lblCommentValue.Content = "Underweight";

            }

            else if (bmi < 25)

            {

                lblCommentValue.Content = "Healthy";

            }

            else if (bmi < 30)

            {

                lblCommentValue.Content = "Overweight";

            }

            else

            {

                lblCommentValue.Content = "Obese";

            }

            l

blCommentValue.Visibility = Visibility.Visible;

            lblComment.Visibility = Visibility.Visible;

        }

 

        private void btnClear_Click(object sender, RoutedEventArgs e)

        {

            txtHeight.Text = "";

            txtWeight.Text = "";

            cmbUnit.SelectedIndex = 0;

            lblResultValue.Visibility = Visibility.Hidden;

            lblResult.Visibility = Visibility.Hidden;

            lblCommentValue.Visibility = Visibility.Hidden;

            lblComment.Visibility = Visibility.Hidden;

        }

 

        private void cmbUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)

        {

            if (cmbUnit.SelectedIndex == 0)

            {

                lblHeight.Content = "Height (inches)";

                lblWeight.Content = "Weight (pounds)";

            }

            else

            {

                lblHeight.Content = "Height (cm)";

                lblWeight.Content = "Weight (kg)";

            }

        }

    }

}





To Get more Subjects GDB's Assignments etc  Click Below on link & Find your Subject

 

GDB’s                                          Click Here

Assignments                                 Click Here

Handouts                                      Click Here

Our Services                                Click Here

CCNA Course                                          Click Here