An "If" question for a budget that refers back to two different cells - - if-statement

I am trying to create a formula to use in a budget spreadsheet. This particular section I am struggling with is in the savings section. I want to create a formula that will pull money from my paycheck balance (reflected in one cell) if it reflects a negative number (meaning I am taking money from my savings), however if it is a positive number (meaning I am adding money to my savings) it will just add to the current balance of the savings (another cell). I hope this makes sense and someone can help.
I can't think of the right formula to even begin.

Related

Google Sheets hours worked before and after specified time

I am trying to specify a time that starts a shift premium for a time card. I was so happy I finally figured out how to get it, but then I changed a time to a first shift time and thats when I lost all hope. I have spent hours messing with this and my current formula's looks like
x1.05
=IF(COUNT(A20:B20)=2,MOD($B$18-A20,1)*24,"")
x1.1
=IF(COUNT(A20:B20)=2,MOD(B20-$B$18,1)*24,"")
My end goal is to have it so first shift (7am - 3pm) fall under base pay, 2nd shift (4pm-12am) fall under x1.05 and anything past 12am falls under x1.1
Just getting this far has been a mind blower for me and any help would be greatly appreciated.
I have moved this to its own sheet to share with everyone. I am still playing with things myself and trying different things, but on the sheet I have included the variables along with the wording of the contract that effects the pay scale. NOTE the times I originally provided were just examples from the top of my head.
My Sheet
It doesn't look like your current sheet accounts for the multiple criteria you're wanting to evaluate. First shift (x1) begins at 7; second shift (x1.05) begins at 15:00, and third shift (x1.10) begins at 24:00.
I added each of those directly above the columns they affect and used this formula for the Base column:
=IF(COUNT($A20:$B20)=2,IF($A20<F$18,(MOD(MIN(F$18,$B20)-$A20,1))*24,0),"")
...this for the x1.05 column:
=IF(COUNT($A20:$B20)=2,IF($A20<G$18,(MOD(MIN(G$18,$B20)-$A20,1)*24)-E20,0),"")
...and this for the x1.10 column:
=IF(COUNT($A20:$B20)=2,(MOD(MIN(E$18+1,$B20)-$A20,1)*24)-SUM(E20:F20),"")
So far, it's working as expected. One thing I didn't add into it is to account for someone who starts their shift before 7 a.m. If you want this to be included in the x1.10 column, you could add a calculation for that to the formula there.
Here's what it looks like:
I'm working in Excel, but these formulas should all work in Google Sheets as well.

How to make an Extended Entry Decision Table for Testing

So I need to make a Decision Table to test a bit of code. The code is simple and straight forward but requires two user inputs to determine two proceeding variables. This is why I need to make this more than a binary (true/false) table.
The user is prompted to input total income, this will, in turn, determine which bracket the user falls into. Then the user is prompted to input the amount of dependents, which will determine the final tax. Depending on the income bracket, a switch statement will then set
tax = income * [certain percentage]. After this the amount of dependents will determine what percentage of the tax will be removed.
Essentially what I need to know is how to set up my Conditions, Actions, and Rules.
Here is an example of decision table but this one is binary (true/false)
I am using Java for the code but that isn't entirely relevant. What I need specifically is deciding what my Conditions should be, whether it's solely income or the combinations of income and dependents, etc. I do not need to write the code, just need to write the test table for it.
If anyone can help inform me as to what I should do or where I should look, that would be appreciated. I am willing to provide anymore information if need be!
Thanks!
If you understand, what the regular (binary) decision table is, then it'll be easy for you to get the extended table as well - the difference is in conditions only.
Conditions in the extended decision table can have more than two values. For example, in your case you have two conditions:
Tax Bracket with values (for example): [0, 9275], [9276, 37650], [37651, 91150] etc.
Number of Dependents with values: 0, 1, 2, 3 etc. (what's the max?)
For Actions I'd choose the tax rate and the deduction amount - they depend on the bracket and on the number of dependents correspondingly.
Rules (=columns in the table) connect conditions and actions - for all the possible combinations of condition values you have a list of actions to perform. In your case these actions will be simply two numbers, which you will use in a tax formula.
(Frankly I don't see why you need a decision table in this case at all... I think, the tax formula with parameters, depending on income, will be enough)

Understanding "Real world modelling" program

Few days now I've got new project to do related with a "real world modelling" program.
Here's how it looks like:
A visit to a psychologist (Use queue). Experts provides psychologist's advice, some of them (n) forms therapeutic groups of k people (GrT - duration of group therapy in hours), other experts (m) takes individual patients (InT - duration of individual therapy in hours). Each newly came patient (new patient's appearance probability is p1, recurring patients comes after period of time (h)) can choose to go to a psychologist providing individual therapies, or to group therapies. If group therapy session is full, patients who are wishing to participate in group sessions must wait. Recurring patients wishing to go to group sessions can start a session with smaller group, but can't go to same session with newly came patients. It has been observed that patients who took individual therapy are recovering faster than those, who chose group sessions(they will need less sessions), but there are exceptions - due to social interaction factor, some patients (probability p2) recover h percent faster than those, who choose individual therapy. Individual session costs InC, group session GrC. You need to assess what therapeutic approach patient should choose optimizing with their resources, and how many and what specialists should hire a health care facility.
Here's my approach to this problem:
Read text file containing Names, Surnames, money willing to spend and place everything in queue structure.
Find which group is better for patient by generating random number for p2probability and using it, we'll find if patient recover faster in individual or group therapy. IMO factor sequence here: Money(looking, if patient can afford individual therapy sessions) > p2 (should patient take group sessions if it's better for him).
By looking how many patients there are in queue, we can find how many psychologists we'll need. (Are there any other factors here? What if we are short of experts?)
Problems that I can't understand: how do I implement p1 probability of new patients appearance if I write every patient into a text file and put them in a queue? How many therapy sessions does it take for patient to recover (static number?)?
Am I missing something? Basically it's open question and there could be no right answer. If anyone have any suggestions how to build this program to better one, I'd be glad to take it!
Programming language I'm using: C++
If you want to break up a task, analyse it and prepare it for coding, you could :
Firstly make a Block diagram, representing program flow control.
Followed by Pseudo code implementation.
P.S. update the question following the above and when you reach the "code stage", there, definitely, will be more help.

average hourly traffic over the year

After hours of searching the web (including SO), I am requesting advice from the community. RRD seems to be the right tool for this, but I could not get a straight answer until now.
My question is : Is it possible to get RRD output a graph for the day, that averages data from the past year ?
In other words, I want the "view span" to be one day long, but the "data span" to extend over the last 12 months, so that for 6pm, the value will be computed as the average value of ALL previous traffic measured at 6pm last 12 months.
Any hints, or instructions welcomed!
There is no direct way to create such a graph, at least in theory it would be possible using multiple DEF lines together with the SHIFT operation to create such a chart ... you would have to use a program to create the necessary command line though

Trouble calculating correct decimal digits

I am trying to create a program that will do some simple calculations, but am having trouble with the program not doing the correct math, or placing the decimal correctly, or something. Some other people I asked cannot figure it out either.
Here is the code: http://pastie.org/887352
When you enter the following data:
Weekly Wage: 500
Raise: 3
Years Employed: 8
It outputs the following data:
Year Annual Salary
1 $26000.00
2 $26780.00
3 $27560.00
4 $28340.00
5 $29120.00
6 $29900.00
7 $30680.00
8 $31460.00
And it should be outputting:
Year Annual Salary
1 $26000.00
2 $26780.00
3 $27583.40
4 $28410.90
5 $29263.23
6 $30141.13
7 $31045.36
8 $31976.72
Here is the full description of the task:
8.17 ( Pay Raise Calculator Application) Develop an application that computes the amount of money an employee makes each year over a user- specified number of years. Assume the employee receives a pay raise once every year. The user specifies in the application the initial weekly salary, the amount of the raise (in percent per year) and the number of years for which the amounts earned will be calculated. The application should run as shown in Fig. 8.22. in your text. (fig 8.22 is the output i posted above as what my program should be posting)
Opening the template source code file. Open the PayRaise.cpp file in your text editor or IDE.
Defining variables and prompting the user for input. To store the raise percentage and years of employment that the user inputs, define int variables rate and years, in main after line 12. Also define double variable wage to store the user’s annual wage. Then, insert statements that prompt the user for the raise percentage, years of employment and starting weekly wage. Store the values typed at the keyboard in the rate, years and wage variables, respectively. To find the annual wage, multiply the new wage by 52 (the number of weeks per year) and store the result in wage.
Displaying a table header and formatting output. Use the left and setw stream manipulators to display a table header as shown in Fig. 8.22 in your text. The first column should be six characters wide. Then use the fixed and setprecision stream manipulators to format floating- point values with two positions to the left of the decimal point.
Writing a for statement header. Insert a for statement. Before the first semicolon in the for statement header, define and initialize the variable counter to 1. Before the second semicolon, enter a loop- continuation condition that will cause the for statement to loop until counter has reached the number of years entered. After the second semicolon, enter the increment of counter so that the for statement executes once for each number of years.
Calculating the pay raise. In the body of the for statement, display the value of counter in the first column and the value of wage in the second column. Then calculate the new weekly wage for the following year, and store the resulting value in the wage variable. To do this, add 1 to the percentage increase (be sure to divide the percentage by 100.0 ) and multiply the result by the current value in wage.
Save, compile and run the application. Input a raise percentage and a number of years for the wage increase. View the results to ensure that the correct years are displayed and that the future wage results are correct.
Close the Command Prompt window.
We can not figure it out! Any help would be greatly appreciated, thanks!
Do not store money as floating point. This will end only in tears. Store money as an integral number of cents.
The reason for this is that floating point math on a computer is necessarily inexact. You know that 0.40 / 2 = 0.20, but it's entirely possible that the computer will say it is 0.19999999999999, and that is not an error. The internal representation of floating point numbers makes it impossible for a computer to exactly represent some fractions, much like you cannot write out an exact decimal representation of 1/3 (without an infinite amount of paper).
When you are dealing with numbers that have fractional parts and for which inexactness is not acceptable (e.g. money), you must compute using fixed-point math. In general, you might use a fixed point library, but for an assignment like this, if you're not allowed to do so, an int that stores a number of pennies will do just fine, so long as you understand how integer division works. You will have to write more math code and account for the rounding yourself, though. But that's what you want. You want absolute control over rounding.
I changed your for loop to this:
cout << (i+1) << " $" << wage*52 << "\n";
wage = wage * (1+(raise/100.0));
And it did worked!. I see you didn't understand the language of the problem.
I think that the intention is to receive a 3% raise each year, but you are actually only adding 3% of the starting salary ($780 in this case) each year. You may want to explore modifying the wage value on each pass in the loop (I won't present a solution as I suspect that this is a homework problem, yes?).
The best way to catch this sort of problem is to run it in a debugger and step through each line looking for when the results don't match your expectations. It's usually pretty easy at that point to figure out where your logic went astray.
Your problem is that your program ignores compounding. You are calculating the dollar value of the raise once, and using that for each increase. Once you get your first raise, the value of your second raise needs to be calculated based on your new wage, not your original wage.