iOS Need Help With Logic/Equation

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,224
123
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??
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
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.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
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.
 

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,224
123
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.


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:
- (IBAction)addDeposit:(id)sender
{
    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?
 

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,224
123
No programming experience huh?


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.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
This helps the OP...
To post this...

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.
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!
 

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,224
123
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!



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.
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
After doing that, you write something like this:
Code:
- (IBAction)addDeposit:(id)sender
{
    amount / deposit *100 = charge;

{
I don't understand.

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

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
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.
return totalAmount;
}
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.
 

CheesePuff

macrumors 6502a
Sep 3, 2008
745
499
Southwest Florida, USA
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...
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,696
4,304
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...
Really? I got worried that employers didn't know what they were looking for and would overlook me...
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Ever look for contracts on the online programming sites? Lowball prices win the contracts. Most of the customers are cheapskates.
 

North Bronson

macrumors 6502
Oct 31, 2007
395
1
San José
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!!!"
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. . .
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.