My Math Forum Math Equation with no conditional logic needed for programming

 Algebra Pre-Algebra and Basic Algebra Math Forum

 May 27th, 2016, 03: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 1-4 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 1-4 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! Thanks from manus Last edited by skipjack; May 27th, 2016 at 04:22 PM.  May 28th, 2016, 10:31 AM #2 Senior Member Joined: May 2016 From: USA Posts: 1,310 Thanks: 551 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).\$ Thanks from manus
May 28th, 2016, 07:11 PM   #3
Math Team

Joined: Oct 2011

Posts: 14,419
Thanks: 1025

Quote:
 Originally Posted by mminten 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).
If total = 5, then invoice = 190 else invoice = 155

May 28th, 2016, 08:42 PM   #4
Senior Member

Joined: May 2016
From: USA

Posts: 1,310
Thanks: 551

Quote:
 Originally Posted by Denis If total = 5, then invoice = 190 else invoice = 155
Mon ami

It is exactly that kind of conditional that he says is unsupported by his software.

 May 28th, 2016, 09:00 PM #5 Math Team   Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 14,419 Thanks: 1025 Merci Jeffroi. Would help if I read slowly and fully... Thanks from manus

 Tags conditional, equation, logic, math, needed, programming

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post dmnte Computer Science 0 April 23rd, 2015 10:45 PM elasolova Computer Science 10 November 26th, 2009 06:16 AM atc Advanced Statistics 2 April 1st, 2009 01:02 PM jumpman23 Applied Math 3 January 20th, 2009 12:23 PM atc Applied Math 0 December 31st, 1969 04:00 PM

 Contact - Home - Forums - Cryptocurrency Forum - Top