Hi
My name is PJ and i'm an adult student who requires a pointer in the right direction. Below is a snippett of the code that i believe i have something wrong in but cant work out what i have done wrong. The code is meant to:
Allow income to be entered and return a tax % rate.
<38000.00 meant to display 19.5%
>38000.00 but <60000.00 meant to display 33.0%
>60.000 meant to display 39.0%
It does not do this (it still displays dollar amounts) EG: enter 41000.00 as taxable income and the answer is 21525.00, and i have struggled with this for days, i need some guidance in the right direction, please The code is as follows: if (dectaxableIncome >= 38000)
dectax = dectaxableIncome * 19.5m / 100; if (dectaxableIncome > 38000 && dectaxableIncome <= 60000)
dectax = dectaxableIncome * 19.5m / 100;
dectax = dectax + dectaxableIncome * 33m / 100; if (dectaxableIncome > 60000)
dectax = dectaxableIncome * 19.5m / 100;
dectax = dectax + dectaxableIncome * 33m / 100;
dectax = dectax + dectaxableIncome * 39m / 100;
9 1395
I think the first if should be if(dectaxableIncome <= 38000)
Raghu
I think the first if should be if(dectaxableIncome <= 38000)
Raghu
I'd love to say yes, but no that does not work either, thanks for trying to help though
What is the code - dectax = dectaxableIncome * 19.5m / 100;
supposed to be doing?
What is the code - dectax = dectaxableIncome * 19.5m / 100;
supposed to be doing?
dividing every hundered dollars by 19.5%...... have a not quite understood this very well? I'm a first year student wanting to excel in this area, and we have had to develop this from pseudocode that was provided.
Hi
My name is PJ and i'm an adult student who requires a pointer in the right direction. Below is a snippett of the code that i believe i have something wrong in but cant work out what i have done wrong. The code is meant to:
Allow income to be entered and return a tax % rate.
<38000.00 meant to display 19.5%
>38000.00 but <60000.00 meant to display 33.0%
>60.000 meant to display 39.0%
It does not do this (it still displays dollar amounts) EG: enter 41000.00 as taxable income and the answer is 21525.00, and i have struggled with this for days, i need some guidance in the right direction, please
Your code doesn't reflect the logic you just described; it should be something
like this: -
if (income < 38000) percentage= 19.5;
-
else if (income < 60000) percentage= 33.0; // income is >= 38000 here
-
else percentage= 39.0; // income is >= 60000 here
-
btw, this is the C and C++ forum, not the C# forum but in this particular case
it doesn't matter much.
kind regards,
Jos
For your description I would have expected something like ... - double rate = 0.0;
-
if(enteredAmount < 38000) {
-
rate = 19.5;
-
}
-
else if(enteredAmount < 60000) {
-
rate = 33;
-
}
-
else if ( .....
For your description I would have expected something like ... - double rate = 0.0;
-
if(enteredAmount < 38000) {
-
rate = 19.5;
-
}
-
else if(enteredAmount < 60000) {
-
rate = 33;
-
}
-
else if ( .....
Thankyou for that.... i will work on that and alter things a little
I am moving this to the .NET forum.
In C++ the <, >, >=, etc.. operators don't work as expected for floating point. Perhaps in C# it's different.
Do not double post your questions. If you are unsure where to post your question, the Mods can move it for you, but don't post it twice. It makes it hard for everyone to know what answers have been given and to keep track of information.
I have merged these threads.
MODERATOR
Sign in to post your reply or Sign up for a free account.
Similar topics
by: James Cameron |
last post by:
Hi I'm developing a program and the client is worried about future
reuse of the code. Say 5, 10, 15 years down the road. This will be a
major factor in selecting the development language. Any...
|
by: Victor Bazarov |
last post by:
In the project I'm maintaining I've seen two distinct techniques used for
returning an object from a function. One is
AType function(AType const& arg)
{
AType retval(arg); // or default...
|
by: Alfonso Morra |
last post by:
Hi,
What is the recomended way of returning an STL container (e.g.
std::string, std::vector etc fom a function?
Is it by simply returning a local variable? (I doubt it)
std::string...
|
by: Michael Hiegemann |
last post by:
Hello,
I am unaware whether this is the right group to ask. Please point me
to another forum if required.
I would like to replace a Fortran function by one which is written in
C. The function...
|
by: napi |
last post by:
I think you would agree with me that a C compiler that directly
produces Java Byte Code to be run on any JVM is something that is
missing to software programmers so far. With such a tool one could...
|
by: Andy_Khosravi |
last post by:
I'm an entry-level VBA programmer that is almost entirely self-taught.
This means that while I have adequate knowledge of VBA in some areas, I
have several gaps in others that may seem obvious to...
|
by: Programador |
last post by:
I'm getting this error when running this program:
Cannot calculate rate using the arguments provided
Module Module1
Sub Main()
Rate(360, -694.44444444444446, 244274.69178082192)
End Sub
|
by: k1ngdrew |
last post by:
I am trying to use mshtml to parse a web page without using IE.
I create the HTMLDocument object, and then assign to it the output value from createDocumentFromUrl().
I know that this is at least...
|
by: Dimitrios Apostolou |
last post by:
Hello list,
I want to limit the download speed when using urllib2. In particular,
having several parallel downloads, I want to make sure that their total
speed doesn't exceed a maximum value.
...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |