POS 409 Week 4 Exception Handling

Using Microsoft® Visual Studio®, write an application to find the area and perimeter of a rectangle for the given input values of Length and Width in different measurement units using inches (in), feet (ft), meters (m), and centimeters (cm).

In addition, write an AreaConverter class that can be used to convert output in different measurement units. If the user enters a negative number or a nonnumeric value, throw and handle an exception. Your solution should include exception-handling techniques with a minimum of two catch clauses.

This tutorial includes two C# project Console Application and Windows Form Application.



This slideshow requires JavaScript.


This assignment includes a Visual Studio (c#) project

  • Attachments
    • POS_409_Week_4_Console.zip (147.72 KB)
      • POS409-Week-4-Console-Screenshot.png
      • Visual Studio project
        • POS409Week4
          • POS409Week4
            • App.config
            • AreaConverter.cs
            • bin
              • Debug
                • POS409Week4.exe
                • POS409Week4.exe.config
                • POS409Week4.pdb
                • POS409Week4.vshost.exe
                • POS409Week4.vshost.exe.config
                • POS409Week4.vshost.exe.manifest
            • NumberNegativeException.cs
            • obj
              • Debug
                • DesignTimeResolveAssemblyReferencesInput.cache
                • POS409Week4.csproj.FileListAbsolute.txt
                • POS409Week4.exe
                • POS409Week4.pdb
                • TempPE
              • POS409Week4.csproj
              • Program.cs
              • Properties
                • AssemblyInfo.cs
            • POS409Week4.sln
            • POS409Week4.v12.suo
      Preview random excerpt
      xxxxxxx xxxxxx xxxxxx[] xxxxx = { "xx", "xx", "x", "xx" };
      xxxxxxx xxxxxx xxxxxx[] xxxxxx = { 2.54, 30.48, 100, 1 };
      //xxxxxxx xxxxxxxxx xx xxxxxxxxx xxxxxxxxxxx xxxxx
      xxxxxx
      static
      xxxxxx
      perimeterConvert(string unit1, string
      xxxxx
      ,
      xxxxxx
      are) {
      xxxxxx
      value1 = 0;
      xxx
      (int
      x
      =
      x
      ; i <
      x
      ;
      x
      ++)
      xx
      (
      xxxxx
      .Equals(UNITS[i])) {
      xxxxxx
      = VALUES[
      x
      ];
      xxxxx
      ; }
      xxxxxx
      value2 = 0;
      xxx (xxx x = 0; x < 4; x++)
      xx (xxxx2.xxxxxx(xxxxx[x]))
      {
      - - - more text follows - - -
      Preview random excerpt
      xxxxx xxxxxx;
      xxxxx xxxxxx.xxxxxxxxxxx.xxxxxxx;
      xxxxx xxxxxx.xxxx;
      xxxxx xxxxxx.xxxx;
      xxxxx xxxxxx.xxxxxxxxx.xxxxx;
      xxxxxxxxx
      POS409Week4 {
      xxxxx
      NumberNegativeException :
      xxxxxxxxx
      {
      xxxxxx
      NumberNegativeException() { }
      xxxxxx
      NumberNegativeException(string message)
      : xxxx(xxxxxxx)
      {
      }
      - - - more text follows - - -
      Preview random excerpt
      xxxxxxx xxxxxx xxxxxx[] xxxxx = { "xx", "xx", "x", "xx" };
      xxxxxxx xxxxxx xxxxxx[] xxxx_xxxxx = { "xxxxxx xxxx", "xxxxxx xxxx", "xxxxxx xxxxx", "xxxxxx xxxxxxxxxx" };
      xxxxxxx xxxxxx xxxxxx[] xxxxxxxxx_xxxxx = { "xxxxxx", "xxxx", "xxxxxx", "xxxxxxxxxxx" };
      xxxxxx xxxx xxxx(xxxxxx[] xxxx)
      {
      xxxx
      xxxxxxxx
      =
      xxxxx
      ;
      xxxxxx
      width = 0;
      xxxxxx
      length = 0;
      xxxxx
      (!
      xxxxxxxx
      ) {
      xxxxxxx
      .Write(
      xxxxxx
      the
      xxxxxxxxxxx
      xx
      length
      xxx
      the
      xxxxxxxxx
      : ");
      xxx
      {
      xxxxxx
      =
      xxxxxx
      .Parse(
      xxxxxxx
      .
      xxxxxxxx
      ());
      xx (xxxxxx < 0)
      xxxxx xxx xxxxxxxxxxxxxxxxxxxxxxx();
      xxxxxxxx = xxxx;
      - - - more text follows - - -

      • POS_409_Week_4_Windows_Form.zip (164.28 KB)
        • POS409-Week-4-Windows-Form-Screenshot.png
        • Visual Studio project
          • POS409Week4_WindowsForm
            • POS409Week4_WindowsForm
              • App.config
              • AreaConverter.cs
              • bin
                • Debug
                  • POS409Week4_WindowsForm.exe
                  • POS409Week4_WindowsForm.exe.config
                  • POS409Week4_WindowsForm.pdb
                  • POS409Week4_WindowsForm.vshost.exe
                  • POS409Week4_WindowsForm.vshost.exe.config
                  • POS409Week4_WindowsForm.vshost.exe.manifest
              • Form1.cs
              • Form1.Designer.cs
              • NumberNegativeException.cs
              • obj
                • Debug
                  • DesignTimeResolveAssemblyReferences.cache
                  • DesignTimeResolveAssemblyReferencesInput.cache
                  • POS409Week4_WindowsForm.csproj.FileListAbsolute.txt
                  • POS409Week4_WindowsForm.csproj.GenerateResource.Cache
                  • POS409Week4_WindowsForm.csprojResolveAssemblyReference.cache
                  • POS409Week4_WindowsForm.exe
                  • POS409Week4_WindowsForm.Form1.resources
                  • POS409Week4_WindowsForm.pdb
                  • POS409Week4_WindowsForm.Properties.Resources.resources
                  • TempPE
                • POS409Week4_WindowsForm.csproj
                • Program.cs
                • Properties
                  • AssemblyInfo.cs
                  • Resources.Designer.cs
                  • Settings.Designer.cs
                  • Settings.settings
              • POS409Week4_WindowsForm.sln
              • POS409Week4_WindowsForm.v12.suo
        Preview random excerpt
        xxxxxxx xxxxxx xxxxxx[] xxxxx = { "xx", "xx", "x", "xx" };
        xxxxxxx xxxxxx xxxxxx[] xxxxxx = { 2.54, 30.48, 100, 1 };
        //xxxxxxx xxxxxxxxx xx xxxxxxxxx xxxxxxxxxxx xxxxx
        xxxxxx
        static double perimeterConvert(string unit1,
        xxxxxx
        unit2,
        xxxxxx
        xxx
        ) {
        xxxxxx
        value1 =
        x
        ;
        xxx
        (
        xxx
        x
        = 0;
        x
        < 4; i++)
        xx
        (unit1.Equals(UNITS[
        x
        ])) {
        xxxxxx
        = VALUES[
        x
        ];
        xxxxx
        ; }
        xxxxxx
        xxxxxx
        = 0;
        xxx (xxx x = 0; x < 4; x++)
        xx (xxxx2.xxxxxx(xxxxx[x]))
        {
        - - - more text follows - - -
        Preview random excerpt
        xxxxxxxxx xxx409xxxx4_xxxxxxxxxxx
        {
        xxxxxx xxxxxxx xxxxx xxxx1 : xxxx
        {
        xxxxxxx xxxxxx xxxxxx[] xxxxx = { "xx", "xx", "x", "xx" };
        xxxxxxx
        static string[]
        xxxxxxxxxx
        = {
        xxxxxxx
        inch", "square
        xxxxx
        , "square
        xxxxxx
        , "square centimeter" };
        xxxxxxx
        static string[] PERIMETER_UNITS = {
        xxxxxxxx
        , "feet", "meters", "centimeters" };
        xxxxxx
        Form1() { InitializeComponent(); }
        xxxxxxx
        void
        xxxxxxxxxx
        (
        xxxxxx
        sender, EventArgs e) {
        xxxxxxxx.xxxxxxxxxxxxx = 0;
        xxxxxxxxxxxxx.xxxxxxxxxxxxx = 0;
        xxxxxxxxxxxxxxx.xxxxxxxxxxxxx = 0;
        - - - more text follows - - -
        Preview random excerpt
        xxxxx xxxxxx;
        xxxxx xxxxxx.xxxxxxxxxxx.xxxxxxx;
        xxxxx xxxxxx.xxxx;
        xxxxx xxxxxx.xxxx;
        xxxxx xxxxxx.xxxxxxxxx.xxxxx;
        xxxxxxxxx
        POS409Week4_WindowsForm {
        xxxxx
        NumberNegativeException : Exception {
        xxxxxx
        NumberNegativeException() { }
        xxxxxx
        xxxxxxxxxxxxxxxxxxxxxxx
        (string
        xxxxxxx
        )
        : xxxx(xxxxxxx)
        {
        }
        - - - more text follows - - -
        Preview random excerpt
        xxxxx xxxxxx;
        xxxxx xxxxxx.xxxxxxxxxxx.xxxxxxx;
        xxxxx xxxxxx.xxxx;
        xxxxx xxxxxx.xxxxxxxxx.xxxxx;
        xxxxx xxxxxx.xxxxxxx.xxxxx;
        namespace POS409Week4_WindowsForm {
        xxxxxx
        class Program { /// ///
        xxx
        main
        xxxxx
        point for the
        xxxxxxxxxxx
        . /// [
        xxxxxxxxx
        ]
        xxxxxx
        void Main()
        {
        xxxxxxxxxxx.xxxxxxxxxxxxxxxxxx();
        xxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxx);
        - - - more text follows - - -



      Purchasing Instruction
      List Price: $19
      Buy Now

      Add to Cart

      FLASH SALE
      $59

      $68 Save $9
      POS 409 Entire Course