-1

Application is running, I have two classes within the program but my second class keeps getting this error.

class SandwichBuild 
{
    private string sandwichname;
    private double ingred1, ingred2, ingred3, ingred4;

    public SandwichBuild(string input1, string input2, string input3, string input4, string input5)   //sets variables
    {
        sandwichname = input1;
        ingred1 = double.Parse(input2);
        ingred2 = double.Parse(input3);
        ingred3 = double.Parse(input4);
        ingred4 = double.Parse(input5);
    }

    public void PrintOutput()
    {
        WriteLine(sandwichname + " " + ingred1 + " " + ingred2 + " " + ingred3 + " " + ingred4);  //Output for users responses
    }
}

I need my application to display final responses

Jimi
  • 29,621
  • 8
  • 43
  • 61

1 Answers1

-1

That is the exception that is thrown if you pass a string that is not a double to double.Parse(...).

This code will throw that exception.

 var result = double.Parse("Not a double or even a number.");

So, you are passing a none valid string into your constructor.

Cubicle.Jockey
  • 3,288
  • 1
  • 19
  • 31