0

Here is the code followed by the errors.. It compiles fine, but displays the errors below the code when I run the program.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class GlazerCalc
{

    static void Main()
    {
        double width, height, woodLength, glassArea;
        string widthString, heightString;
        // Console.ReadLine(); asks the user to input a value, and is placed in the widthString variable

        widthString = Console.ReadLine();
        width = double.Parse(widthString);

        heightString = Console.ReadLine();
        height = double.Parse(heightString);

        woodLength = 2 * (width + height) * 3.25;
        glassArea = 2 * (width * height);

        Console.WriteLine("The length of the wood is " +
        woodLength + " feet");

        Console.WriteLine("The area of the glass is " +
        glassArea + " square metres");

    }
}

Unhandled Exception: System.FormatException: Input string was not in a correct format. at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) at System.Double.Parse(String s) at GlazerCalc.Main() in C:\VisualStudio\Learning\Learning\Program.cs:line 19

Debug error: An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: Input string was not in a correct format.

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
Dean Ccfc
  • 1
  • 2

0 Answers0