C
C#4mo ago
stiffening

✅ "debug executable 'location' specified in the [project] debug profile does not exist"

hello, i'm an absolute beginner with c# and am trying to work on a project for school. whenever i rebuild and try to run without debugging, visual studio gives me the error message "debug executable 'location' specified in the [project] debug profile does not exist." (location is the folder, and project is project name; i didn't list them because my professor requires it to have my full name in it and i'd prefer not to post that info online.) this happens when i add some coding. when i remove the coding, it does open the project. i don't know what i'm doing wrong to cause this. the project is supposed to be income tax calculator. the following is the coding i've been trying to use that causes the errors:
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal TaxableIncome = Convert.ToDecimal(txtTaxableIncome.Text);
decimal TaxOwed = Convert.ToDecimal(txtTaxOwed.Text);

if (TaxableIncome <= 0m)
TaxOwed = .0m;

else if (TaxableIncome >= 0m && TaxableIncome <= 11000m)
TaxOwed = 0m + .10m;

else if (TaxableIncome > 11000m && TaxableIncome <= 44725)
TaxOwed = 1100m + (TaxableIncome * .12);

else if (TaxableIncome > 44725 && TaxableIncome <= 95375)
TaxOwed = 5147m + (TaxableIncome * .22);

else if (TaxableIncome > 95375 && TaxableIncome <= 182100)
TaxOwed = 16290m + (TaxableIncome * .24);

else if (TaxableIncome > 182100 && TaxableIncome <= 231250)
TaxOwed = 37104m + (TaxableIncome * .32);

else if (TaxableIncome > 231250 && TaxableIncome <= 578125)
TaxOwed = 52832m + (TaxableIncome * .35);

else if (TaxableIncome < 578125)
TaxOwed = 174238.25 + (TaxableIncome * .37);
}
private void btnCalculate_Click(object sender, EventArgs e)
{
decimal TaxableIncome = Convert.ToDecimal(txtTaxableIncome.Text);
decimal TaxOwed = Convert.ToDecimal(txtTaxOwed.Text);

if (TaxableIncome <= 0m)
TaxOwed = .0m;

else if (TaxableIncome >= 0m && TaxableIncome <= 11000m)
TaxOwed = 0m + .10m;

else if (TaxableIncome > 11000m && TaxableIncome <= 44725)
TaxOwed = 1100m + (TaxableIncome * .12);

else if (TaxableIncome > 44725 && TaxableIncome <= 95375)
TaxOwed = 5147m + (TaxableIncome * .22);

else if (TaxableIncome > 95375 && TaxableIncome <= 182100)
TaxOwed = 16290m + (TaxableIncome * .24);

else if (TaxableIncome > 182100 && TaxableIncome <= 231250)
TaxOwed = 37104m + (TaxableIncome * .32);

else if (TaxableIncome > 231250 && TaxableIncome <= 578125)
TaxOwed = 52832m + (TaxableIncome * .35);

else if (TaxableIncome < 578125)
TaxOwed = 174238.25 + (TaxableIncome * .37);
}
any and all advice appreciated, thanks so much!
17 Replies
Buddy
Buddy4mo ago
Are you getting a build error? Check error log to find out View -> Error Log It should be listed there
stiffening
stiffening4mo ago
is that the same as error list?
Buddy
Buddy4mo ago
Is what the same? Oh, yes. I mean error list
stiffening
stiffening4mo ago
okay, i wanted to make sure im looking at the right thing its giving error CS0019 '*' cannot be applied to operands of type 'decimal' and 'double'
Buddy
Buddy4mo ago
m suffix indicates that the number is of type decimal Without it, it will assume it is a double
stiffening
stiffening4mo ago
oh, so then all the numbers need the m?
Buddy
Buddy4mo ago
Correct Decimal is 128-bit floating point while double is 64-bit floating point. More bits means more precision, which is why you use decimal for currencies
stiffening
stiffening4mo ago
okay, awesome. thanks a bunch! its at least loading it up now, yay!
Buddy
Buddy4mo ago
👏 No problem
stiffening
stiffening4mo ago
...uh oh. so i tried to test it and its giving another exception. the input string '' was not in the correct format. do i need to make a new thread to ask about this? im frankly hopeless and so confused
Buddy
Buddy4mo ago
When you feel like this thread is done, type /close No, it's fine $tryparse
MODiX
MODiX4mo ago
When you don't know if a string is actually a number when handling user input, use int.TryParse (or variants, e.g. double.TryParse)
if(int.TryParse("123", out int number))
{
var total = number + 1;
Console.WriteLine(total); // output: 124
}
if(int.TryParse("123", out int number))
{
var total = number + 1;
Console.WriteLine(total); // output: 124
}
TryParse returns a bool, where true indicates successful parsing. Remarks: - Avoid int.Parse if you do not know if the value parsed is definitely a number. - Avoid Convert.ToInt32 entirely, this is an older method and Parse should be preferred where you know the string can be parsed. Read more here
Buddy
Buddy4mo ago
Localization is mostly the issue in your case Some countries define decimals as 0.22, while other define them as 0,22 (notice comma vs dot) But the recommended is to use TryParse, it returns a boolean whether it successfully parsed it, and the out parameter declares a variable and then sets the value to the result.
stiffening
stiffening4mo ago
i thought the professor told us to use .x to get it to do percentages, but i could be misremembering, so i was multiplying by .x
stiffening
stiffening4mo ago
awesome, thanks!
Want results from more Discord servers?
Add your server
More Posts