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
      public static
      xxxxxx
      perimeterConvert(string unit1,
      xxxxxx
      unit2,
      xxxxxx
      are) {
      xxxxxx
      value1 =
      x
      ;
      xxx
      (int
      x
      = 0; i < 4;
      x
      ++)
      xx
      (
      xxxxx
      .
      xxxxxx
      (UNITS[
      x
      ])) {
      xxxxxx
      = VALUES[
      x
      ];
      xxxxx
      ; }
      xxxxxx
      value2 =
      x
      ;
      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;
      namespace
      xxxxxxxxxxx
      {
      xxxxx
      NumberNegativeException :
      xxxxxxxxx
      {
      xxxxxx
      xxxxxxxxxxxxxxxxxxxxxxx
      () { }
      xxxxxx
      NumberNegativeException(
      xxxxxx
      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
      validate = false;
      xxxxxx
      width = 0;
      xxxxxx
      length =
      x
      ;
      xxxxx
      (!
      xxxxxxxx
      ) {
      xxxxxxx
      .Write("Enter the measurement of length for the rectangle: ");
      xxx
      {
      xxxxxx
      = double.
      xxxxx
      (Console.ReadLine());
      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, string unit2, double
        xxx
        ) {
        xxxxxx
        value1 =
        x
        ;
        xxx
        (int i = 0;
        x
        < 4;
        x
        ++) if (unit1.Equals(
        xxxxx
        [i])) {
        xxxxxx
        =
        xxxxxx
        [i];
        xxxxx
        ; }
        xxxxxx
        xxxxxx
        =
        x
        ;
        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",
        xxxxxxx
        foot", "square meter",
        xxxxxxx
        centimeter" };
        xxxxxxx
        xxxxxx
        xxxxxx
        []
        xxxxxxxxxxxxxxx
        = {
        xxxxxxxx
        ,
        xxxxxx
        , "meters", "centimeters" };
        xxxxxx
        Form1() {
        xxxxxxxxxxxxxxxxxxx
        (); }
        xxxxxxx
        void
        xxxxxxxxxx
        (object sender,
        xxxxxxxxx
        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
        xxxxxxxxxxxxxxxxxxxxxxx
        :
        xxxxxxxxx
        {
        xxxxxx
        xxxxxxxxxxxxxxxxxxxxxxx
        () { }
        xxxxxx
        xxxxxxxxxxxxxxxxxxxxxxx
        (
        xxxxxx
        message)
        : 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 entry point for the application. /// [
        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