|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Hey guys, currently in intro to CS and I have a quick question. The teacher asks us to find the input, output, transformation, and constraints for this problem so we can write a psedu code
Problem: A program needs to be written to compute a wage calculation for a company which has 50 employees. Calculation needs to be based on the following specifications: -Work hours, 40-60 -Tax rate 30% -Overtime count (1 1/2) -Different hourly rate
Here's what I have so far.
Input phase: Work hours, tax rate, overtime, hourly rate, how many employees. Output phase: Total hours, tax on employees, money spent on employees. Transformation: pretax=(hours)+(overtimeHours*1.5) cost=pretax*taxpercentage Constraints: ????
My teacher was very vague at explaining this and all my answers are but a shot in the dark. If anyone could lend some assistance to this budding programmer, that would be much appreciated ^_^
|
how bout leaves or AWOL? does that take into consideration?
|
if (workplace_explosion == true) end program
|
If you're confused all they're saying is that your question is way too broad and non-specific to answer.
|
|
On September 30 2014 02:24 Nesserev wrote: while (true) { try_to_understand_question }
Seriously though... inputThe tax rate is the same for everyone (30%) and thus representable by a simple number, but you'll need lists/arrays containing the workhours, overtime counts and hourly rates for every worker(index), because these can be different for every employee. You do not need a number that explicitely says how many employees there are per se, because this is implicitely given by the lenght of every array. One first 'constraint' is that every array has to have the same length! Second constraint is the fact that the amount of work hours per person has to be between 40-60. Input phase: array_workhours, taxrate, array_overtimecount, array_hourlyrate OutputIf the program is supposed to calculate the 'total' wages that the company has to pay the output is simply one number, the total amount of wages that have to be paid. If the program is supposed to calculate the wages per person, then you have to return an array with the post-taxation wages of every person(index). Third constraint is that the array_costs has to be the same lenght as the arrays used for the input. Output phase: array_costs or totalcost Transformation // for every person: calculate cost pretax = hours * hourlyrate + (overtimeHours * 1.5 ) * hourlyrate cost = pretax + (pretax * taxpercentage)
// append cost to array_costs, or add cost to total_costs
It's not clear how the wages are actually calculated, especially the taxes. Are these taxes that the people have to pay, or the company? Better check these formulas again. constraints- every array in input has to have the same length - work hours per person have to be between 40-60 - output_array has to have the same length as the arrays from the input
Thank you so much kind sir. Cleared it up nicely for me.
|
|
On October 01 2014 13:01 Ninoah wrote:Quick question: Referencing http://bigocheatsheet.com/ under Data Structures. What is a "indexing" operation?
I believe it means grabbing an element out of the structure. e.g. for a simple array, indexing the element a[100] is O(1), but for a list it is O(n) because you have to traverse the list, etc.
|
Do any of you have experience with jQuery cookies?
$.cookie('var', 'val'); // throws uncaught reference error since scripts are being loaded at the bottom of the page
// after finally setting the cookie and testing it in the console (invoking $.cookie('var') returns "val")
window.onload = function () { // need onload to wait for jQuery if ($.cookie('var') === "val") { // can't even test this because the browser crashes before being able to load the page with this code } }
Any ideas?
|
On October 01 2014 13:12 meatpudding wrote:I believe it means grabbing an element out of the structure. e.g. for a simple array, indexing the element a[100] is O(1), but for a list it is O(n) because you have to traverse the list, etc.
+1, good explanation
|
On October 02 2014 00:52 Manit0u wrote:Do any of you have experience with jQuery cookies? $.cookie('var', 'val'); // throws uncaught reference error since scripts are being loaded at the bottom of the page
// after finally setting the cookie and testing it in the console (invoking $.cookie('var') returns "val")
window.onload = function () { // need onload to wait for jQuery if ($.cookie('var') === "val") { // can't even test this because the browser crashes before being able to load the page with this code } }
Any ideas?
Are those comments your question? I am confused as to what you are asking?
|
Oh, forgot to ask the actual question
I need to store a global JS variable on page refresh and execute a script based off of that (this way I'll have to do minimal changes to huge application that's actually live). The problem I'm facing is that something seemingly simple - like storing/getting single value via cookie - is crashing the browser...
Do you know of other ways of doing it? Or making this work?
|
On October 02 2014 04:41 Manit0u wrote:Oh, forgot to ask the actual question I need to store a global JS variable on page refresh and execute a script based off of that (this way I'll have to do minimal changes to huge application that's actually live). The problem I'm facing is that something seemingly simple - like storing/getting single value via cookie - is crashing the browser... Do you know of other ways of doing it? Or making this work?
Ok cool yeah you can use plan ol' javascript to do this.
document.cookie="username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/";
to get this cookie
var oreo = document.cookie;
to change the cookie that is already there you do the same as setting it
document.cookie="username=Jane Doe; expires=Thu, 18 Dec 2014 12:00:00 UTC; path=/";
go here for more info: http://www.w3schools.com/js/js_cookies.asp
Hope this helps!
|
Hyrule18758 Posts
we don't talk about w3schools around here
|
On October 02 2014 07:38 tofucake wrote: we don't talk about w3schools around here
Well for JavaScript Mozilla documentation is definitely better. But w3 isn't too bad
|
In class, we have been going over ArrayLists for java. Something that really confuses me, is how exactly do arraylists store inputs?
if we have to create a 26 sized array and count how many times a letter shows up in a sentence, do we go through the process of using a counter? or do we just keep adding 1 to that section? I've been reading the book and going over lecture notes but im still unsure of how arraylists work.
|
On October 02 2014 04:41 Manit0u wrote:Oh, forgot to ask the actual question I need to store a global JS variable on page refresh and execute a script based off of that (this way I'll have to do minimal changes to huge application that's actually live). The problem I'm facing is that something seemingly simple - like storing/getting single value via cookie - is crashing the browser... Do you know of other ways of doing it? Or making this work?
Why does it have to happen on the unload? Why don't you store the value when it changes to make sure that you aren't waiting until the very end? Have you tried modifying the cookie anywhere other than unload? Does it still crash the browser? Is this the first time you are trying to modify the cookie, you aren't trying to set it on the server first? It's not marked as http only, is it?
I've used jQuery to modify cookies but never seen it crash.
As far as the general solution idea, I think you'd have to get a bit more specific about the problem before anyone could help or judge.
|
Hyrule18758 Posts
On October 02 2014 08:46 YourGoodFriend wrote:Show nested quote +On October 02 2014 07:38 tofucake wrote: we don't talk about w3schools around here Well for JavaScript Mozilla documentation is definitely better. But w3 isn't too bad http://www.w3fools.com/
|
On October 02 2014 10:03 tofucake wrote:Show nested quote +On October 02 2014 08:46 YourGoodFriend wrote:On October 02 2014 07:38 tofucake wrote: we don't talk about w3schools around here Well for JavaScript Mozilla documentation is definitely better. But w3 isn't too bad http://www.w3fools.com/
Oh I understand that mdn is the place to go, it's what I use when looking up anything ecma5 related. But I find that it can be a bit much for non-developers and simple JavaScript (emca3 and back )is usually easy to see and understand on w3.
|
On October 02 2014 09:17 MysteryMeat1 wrote: In class, we have been going over ArrayLists for java. Something that really confuses me, is how exactly do arraylists store inputs?
if we have to create a 26 sized array and count how many times a letter shows up in a sentence, do we go through the process of using a counter? or do we just keep adding 1 to that section? I've been reading the book and going over lecture notes but im still unsure of how arraylists work.
You could iterate through your ArrayList in 3 ways: 1. convert it to a plain array and loop like you would an array (which you seem to already know) 2. use a foreach loop to go through your list, the syntax would be something like:
for (Object a : ArrayList<Object> b) 3. use a ListIterator (you should only use this over foreach if you are going to be modifying the contents of your list as you go through it)
|
|
|
|