The algorithm is for determining the tax that a person has to pay based on his table income.How do i create a C#-based application,the GUI design and the programming code for the following pseudocode.Help me as i am new to C#.
Read taxable income
Set tax =0
If taxableIncome is less than or equal to 3800 Then
Calculate tax (tax=19.5% of 3800)
EndIf
If taxableIncome is more than 38000 and less than or equal to 60000 Then
Calculate tax(tax=19.5% of 3800 + 33% of 60000-38000)
EndIf
If taxableIncome is more than 60000 Then
Calculate tax(tax=19.5% of 3800 + 33% of 60000-38000 +39% of taxable income -60000)
EndIf
How to code this algorithm
Started by reja, May 22 2010 08:40 PM
5 replies to this topic
#1
Posted 22 May 2010 - 08:40 PM
|
|
|
#2
Posted 27 May 2010 - 03:32 AM
please can you explain what do you mean by (taxableIncome)
is it the incomming salary or what?????
is it the incomming salary or what?????
#3
Posted 27 May 2010 - 07:15 AM
taxableIncome is the name given for the variable...taxable income is the income received by a person and the person is being taxed according to his income
#4
Posted 28 May 2010 - 11:17 AM
Set up a text box asking for the user to enter their taxable income and give them a submit button. Somewhere on the page you will want to add a label and show the user the end result of the calculation:
Your code in the codebehind (.cs file) should look something like this:
Code spacing may look bad cause I wrote this up quickly in Notepad++. The code is not perfect but you should get the idea.
Your code in the codebehind (.cs file) should look something like this:
namespace myNamespace
{
class myClass : System.Web.UI.Page
{
double taxibleIncome = 0.0;
double tax = 0.0;
protected override void OnInit( EventArgs e )
{
base.OnInit( e );
this.btnSubmit.Click += new EventHandler( OnSubmitClick );
}
private void OnSubmitClick( object sender, EventArgs e )
{
this.lblTax.Text = this.CalculateTax( this.txtTaxableIncome.Text );
}
private double CalculateTax( double taxableIncome )
{
double result = 0.0;
switch( taxableIncome )
{
case( taxableIncome <= 38000.00 )
// do calculation
break;
case( taxableIncome > 38000.00 && taxableIncome <= 60000.00 )
// do calculation
break;
case( taxableIncome > 60000.00 )
// do calculation
break;
default:
// throw error message
break;
}
return result;
}
}
}
Code spacing may look bad cause I wrote this up quickly in Notepad++. The code is not perfect but you should get the idea.
-CDG10620
Software Developer
Software Developer
#5
Posted 29 May 2010 - 12:16 AM
oh thank you so much for helping.but i dont really understand the method that you have used because the one that my lecturer taught me was using the "If and Else" method....i will try modifying yours and add it to my code,thanks for helping me :)
#6
Posted 30 May 2010 - 06:46 AM
did the code work,if yes please post your algorithm + code here so that members can benefit from the code Greetz


Sign In
Create Account


Back to top









