# Need Help With Logic/Equation

Discussion in 'iOS Programming' started by loon3y, Nov 17, 2011.

1. ### loon3y macrumors 65816

Joined:
Oct 21, 2011
#1
basically theres an amount in one textfield and I'm going to enter the deposit % of the amount thats going to be charged on the next textfield and I want the app to automatically calculate the % deposit and appear in the actually charged textfield.

what would be the equation? like for instance if it was 100 dollars how would i write the code if it war 20%? or 30% like which ever precent the user would put in??

2. ### jiminaus macrumors 65816

Joined:
Dec 16, 2010
Location:
Sydney
#2
Forget about iOS programming for now. Can you come up with the mathematical equations?

If a is the starting amount, p is the deposit percentage and c is the calculated new amount, then what would be the mathematical equation?

One you figure that out, then we can help you implement that equation in terms of your three text fields.

3. ### jnoxx macrumors 65816

Joined:
Dec 29, 2010
Location:
Aartselaar // Antwerp // Belgium
#3
Isn't this pretty math that they teach you in lower grades? making % of a number?
And about the textfields, that's the easiest thing, i'd recommand just wrting it down, how exactly you want it to do. the delegates of UITextField, that's the next thing.

4. ### loon3y thread starter macrumors 65816

Joined:
Oct 21, 2011
#4

ok, lol well i haven't been at school for a while, i should of juz googled it, sorry.

so basically it would be a divided by p multiplied by 100 would equal c the amount charge

how would i write that code?

would that be an IBAction code?

like for instance

Code:
```
{
amount / deposit *100 = charge;

{
```
and how can i make it automatically show up in the charge textfield after i type in the deposit.

would i be using a return command?

Joined:
Dec 16, 2010
Location:
Sydney
6. ### elpmas macrumors 68000

Joined:
Sep 9, 2009
Location:
Where the fresh snow don't go.
#6
This helps the OP...

7. ### loon3y thread starter macrumors 65816

Joined:
Oct 21, 2011
#7

nope, im a nooby, i started 3 months ago.

i read one book, iPad iOS 4 essentials and I'm reading the big nerd book objective c,

but i do have a project that is due sooner or worse later, that customers want.

8. ### jiminaus macrumors 65816

Joined:
Dec 16, 2010
Location:
Sydney
#8
To post this...

This is what really gets by goat. What the ******* does the OP think his doing taking on a contract/job that he's incapable/unqualified to do!

9. ### loon3y thread starter macrumors 65816

Joined:
Oct 21, 2011
#9

the iOS program isn't the main part of the project, its like a side order. its not ESSENTIAL, and I've completed the main part of the app that customers want.

like implementing linea pro to use the barcode scanner to pull inventory, WIP, bin location, etc etc, from a website and the credit card scanner to pull the last 4 numbers and send it to a website.

of course people around me helped me, and i got helped from the forums, i basically have the main thing that most of the customers wanted to show inventory by scanning a barcode. but i have nothing really to do at work right now so i thought it tried to make my program better.

i just simply don't have time to go to formal classes because my work consists of me traveling all the time and also doing other things than programming.

10. ### jiminaus macrumors 65816

Joined:
Dec 16, 2010
Location:
Sydney
#10
After doing that, you write something like this:
I don't understand.

Anyway, I clearly am in no mood to help you, so I'll shut up now. Good luck to you.

11. ### jnoxx macrumors 65816

Joined:
Dec 29, 2010
Location:
Aartselaar // Antwerp // Belgium
#11
Sigh.. You have 3 months, and read through 1 book, and nearly another one. And can't solve it?
Thing is, i don't know if you really know where you wonna go with this, do you want to calucate the second you type, do the calculation on the fly while typing numbers, or do you want it to happen on a button press, it's all questions that should be taken into consideration.

IBAction is just for the button, and then you need to check the VALUE of your textfield, (you can ask doubleValue or intValue from your text value).
THen make a method something like

Code:
```- (int)showAmount:(int)firstValue andSecondValue(int)secondValue
{
int totalAmount = 0;
equasion with parameters firstValue/secondvalue/
totalAmount = ^equasion.
}```
And call that function from within your IBAction. If you have no idea what I was talking about, you go back to the books. sorry to break it to you.

12. ### CheesePuff macrumors 6502

Joined:
Sep 3, 2008
Location:
Southwest Florida, USA
#12
This gives me hope that someday I'll be hired as an iOS developer if this kid apparently has contracts in place and developed an application and can't even assign a value to a variable...

13. ### ArtOfWarfare macrumors G3

Joined:
Nov 26, 2007
#13
Really? I got worried that employers didn't know what they were looking for and would overlook me...

14. ### PhoneyDeveloper macrumors 68040

Joined:
Sep 2, 2008
#14
Ever look for contracts on the online programming sites? Lowball prices win the contracts. Most of the customers are cheapskates.

15. ### nickculbertson macrumors regular

Joined:
Nov 19, 2010
Location:
Nashville, TN
#15
My personal favorite is the frequent listings for "I have a great idea for an app, no pay up front but this app will be HUGE!!!"

16. ### North Bronson macrumors 6502

Joined:
Oct 31, 2007
Location:
San José
#16
It's a good thing my landlord and grocery store both accept equity for payment, otherwise I might have to work for cash. Imagine what kind of a world that would be. . .