
Algebra PreAlgebra and Basic Algebra Math Forum 
 LinkBack  Thread Tools  Display Modes 
May 27th, 2016, 04:24 PM  #1 
Newbie Joined: May 2016 From: Nevada Posts: 1 Thanks: 1  Math Equation with no conditional logic needed for programming
I am using the Ninja Forms plugin for a WordPress website which only allows for basic math calculations using simple operations (+  * or /). You can see the current test form here: Stall Reservation Form Test  One Day One Million PROBLEM Basically the user can reserve any of the 5 dates listed. If they reserve 14 dates the cost is \$155.00 but if they reserve a 5th date the cost is \$190.00 (adding \$35). FIRST SOLUTION (NOT WORKING) Right now, I gave each DATE a value of 1. I then told it to add up the total # of dates (resulting in any number from 1  5). I created a Date Calculation field (DC) with the equation: DATE/4 = x and I wanted to use this to say: If x > 1 then COST + \$35.00 = TOTAL COST. The problem with this solution is that there is no conditional logic in the form software to adjust the numbers live with user interaction. I have to think of another equation that can add \$35.00 to the total COST if they select 5 dates. POSSIBLE SOLUTION The only thing I can think of is an equation (using basic math operators) that that can make x = 1 if 5 dates are selected and x = 0 if 14 dates are selected. Then I can just say COST + 35x = TOTAL COST. Resulting equations would be: 1  4 dates: 155 + (35 * 0) = 155 5 dates: 155 + (35 * 1) = 190 I have no idea how to do this using basic operators and no conditional logic while programming. We can give each date any number value, but we must realize that the user may not want any single night in the list. This means that they may reserve all the dates or just Sun  Wed or maybe Sat  Tues or even just not Monday. In this case, all values for the dates should be the same. Thanks in advance to any math geniuses that can figure this one out! Last edited by skipjack; May 27th, 2016 at 05:22 PM. 
May 28th, 2016, 11:31 AM  #2 
Senior Member Joined: May 2016 From: USA Posts: 1,300 Thanks: 549 
Assign a variable for each date, say a for the first date, b for the second date. If date 1 is chosen, a = 1; if a is not chosen, a = 0. I am presuming that you can code differently dates chosen and not chosen. $Total\ cost = 155 + (a * b * c * d * e * 35).$ 
May 28th, 2016, 08:11 PM  #3 
Math Team Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 13,938 Thanks: 984  
May 28th, 2016, 09:42 PM  #4 
Senior Member Joined: May 2016 From: USA Posts: 1,300 Thanks: 549  
May 28th, 2016, 10:00 PM  #5 
Math Team Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 13,938 Thanks: 984 
Merci Jeffroi. Would help if I read slowly and fully... 

Tags 
conditional, equation, logic, math, needed, programming 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
prove logic equation, logic algebra  dmnte  Computer Science  0  April 23rd, 2015 11:45 PM 
math team needed for programming community  elasolova  Computer Science  10  November 26th, 2009 07:16 AM 
math logic programming  atc  Advanced Statistics  2  April 1st, 2009 02:02 PM 
Linear Programmingurgent help needed!  jumpman23  Applied Math  3  January 20th, 2009 01:23 PM 
math logic programming  atc  Applied Math  0  December 31st, 1969 04:00 PM 