Question: C# Debugging help // Handles a Format Exception if user does not enter a number using System; using static System.Console; class DebugEleven01 { static void

C# Debugging help

// Handles a Format Exception if user does not enter a number
using System;
using static System.Console;
class DebugEleven01
{
static void Main()
{
double salary;
string salVal;
bool isValidSalary;
while(!isValidSalary)
{
try
Write("Enter an employee's salary ");
salVal = ReadLine();
salary = Convert.ToDouble(salVal);
isValidSalary = true;
catch(Formatexception fe)
{
WriteLine("You must enter a number for the salary");
}
}
WriteLine("The salary {0} is valid", salary.ToString("C2"));
}
}

Step by Step Solution

3.22 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code you provided is intended to handle a FormatException when a user enters something that is not a number for an employees salary However there ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

606ad5685c407_47907.pdf

180 KBs PDF File

Word file Icon

606ad5685c407_47907.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!