CS411 Assignment: 02 Solution

Assignment Details

Due Date:

Monday 23, June, 2025

Extended Date:

Tuesday 24, June, 2025


Assignment Question Details:

CS411 – Visual Programming

Assignment No. 02
Semester: Spring 2025

Instructions:

Please read the following instructions carefully before submitting the assignment:

You need to use MS word document to prepare and submit the assignment on VU-LMS.

It should be clear that your assignment will not get any credit if:

§  The assignment is submitted after the due date.

§  The assignment is not in the required format (doc or docx).

§  The submitted assignment does not open, or file is corrupt.

§  If you didn’t use your own VU ID, you will get zero marks.

§  Paste your both files code in given solution sample on next page of this assignment.

§  Only upload solution file, do not add assignment file in it.

§  No assignment will be accepted in any case after the due date, if you face any issue while uploading take screen shot of issue and paste in mail along with assignment file to cs411@vu.edu.pk within due date, otherwise your assignment and issue will not be accepted.

 

Objectives:

The objective of this assignment is to enhance the learning capabilities of the students about:

§  Developing simple applications using WPF XAML

§  Using C# programming language with WPF XAML

Problem Statement:

You are required to develop a WPF application in C# that converts a temperature from Fahrenheit to Celsius. The application should consist of a clean and simple interface built using WPF in xaml (MainWindow.xaml), and the conversion logic should be implemented in C# (MainWindow.xaml.cs).

 

Step 1: Create WPF App (.Net Framework):


While creating WPF application in visual studio choose this option.

 

Step 2: UI Design Instructions (MainWindow.xaml):

 

You must create the following interface elements using XAML:

  1. Top Label
    • Display your VU ID (e.g., VU1234567)
    • Style: Bold, Large font size (24 or more), cantered
  2. Input Label
    • A Label with the text “Input Fahrenheit:”
    • Style: Font Size 14 or higher, Bold
  3. Input Textbox
    • A Textbox for the user to enter the Fahrenheit temperature
    • Style: reasonable height and font for clear visibility
  4. Convert Button
    • A Button labelled “To Celsius”
        • Style:
          • Background: Green
          • Foreground: White
          • Bold text, large enough to stand out
        • This button should trigger the temperature conversion
      1. Result Label
        • A Label to display the conversion result e.g.

      Result: 37.78 °C

        • Style: Bold, medium or large font

      All elements should be arranged vertically using a Grid or Stack Panel, with proper margins.

       

      Step 3: C# Code Instructions (MainWindow.xaml.cs):

       

      In the code-behind file MainWindow.xaml.cs, you must:

      1. Create a button click event handler for the “To Celsius” button.
      2. In the event handler:
        • Read the value entered in the Textbox
        • Convert the input from Fahrenheit to Celsius using the formula:

      Celsius = (Fahrenheit - 32) × 5 / 9

        • Format the result to 2 decimal places

      e.g., Result: 37.78 °C

      1. If the input is not a valid number, show an error message using a Message Box.

       

      Sample Output:

VuPark Pending

Thursday 19, June, 2025

VuPark Pending

Tuesday 24, June, 2025