Assignment 01

Due: Thursday, Jan. 26, 2017 at noon 50 pts.

For this assignment, you will type and submit three (3) algorithms. Make your algorithms clear and concise step-by-step procedures that solve the problems given. I think that each of these should require at least three steps and probably (though, possibly) no more than twenty steps. Think about your answers.

You are to edit a single file in your DFS account using an editor (I like jpico) that your lab instructor has shown you in your CS 1580 lab #1( or #0 depending on who your lab instructor is). First though, make a new directory under your home directory and call it cs1570 (from home, type mkdir cs1570 and enter). Change into that directory (cd cs1570). Now, make a new directory under this cs1570 directory and name it hw1. Change into that directory and then create the file with your answers in it, naming it something clever like "hw1.txt". The .txt extension is used for files that are nothing but text (not to be compiled). What ever you name that file, make sure it has a .txt extension. This assignment is NOT C++ programming. You are not to compile this. In this (one and only) file (for this assignment), you are to number your answers for the following 3 problems. Also, be sure to put your name and section letter at the top!!

  1. You've graduated from college and you have your first job in industry. Having now secured a very prestigious job working for the egg producers of greater

  1. Northwest Arkansas, you wish to impress your employer with your scientific acumen. You've been given the task of determining the highest floor of the Eggtromics International sky-scraper in downtown Bentonville, AR, from which an egg can be dropped without breaking on the grass-lawn below. Being a good and faithful employee, you have decided NOT to ask why. Good decision. Thus, you want to know if the 5th floor balcony is the highest floor from which you can drop an egg and have it survive, or is it the 8th, or is the 15th or is the 2nd. Write an algorithm that most efficiently determines this. The building is 99 floors (eggs are important!) and you are given seven eggs (very important) and there is a chupacabra at the bottom so you cannot retrieve the eggs once used (or el chupra will eat you!). Write an algorithm that will instruct anyone trying to perform this task how to do it.You've taken a new job with a big-city bank that just opened in your little town. You have plenty of opportunities to work over-time, so the boss lays out the rules for over-time pay. They are:

    • Over-time pay (OP) is calculated and paid every four weeks (based on your starting date), so it depends on work activity in 4-week increments.

    • Each day is 8 hrs; each week is 40 hrs.

    • For each 4-week period, a worker gets 2 paid sick leave days, but the first day must be no earlier than week #2, and the second no earlier than week #4.

    • If a sick day does not follow that rule, then any over-time worked will go towards "paying back" such a sick day. (ex. Bob is sick 1 day in week #1 and works 10 extra hours in that 4-week period. He is only paid for 2 hrs extra since the other 8 hrs went towards the unqualified sick day.)

    • Normal OP is paid at a rate of 1.5 times base pay. This rate is paid for 30 hrs or less of over-time.

    • Extreme OP is paid at a rate of 2.0 times base pay. This rate is paid for the hours of over-time exceeding 30 hours.

    • If a worker takes only one qualifying sick day, and accumulates 40 or more over-time hours in any single week, then they are paid OP for their over-time according to the above rules AND an additional lump sum of 30 times their base pay.

    • If a worker works 80 or more over-time hours in a pay period and took no sick days, they are summarily terminated ("YOU'RE FIRED!") for making everyone else, including the boss, look bad....really bad. Their OP is just $5, enough for a bus ride out of town!

    1. Write an algorithm that queries the user for work information and outputs their employment status (still working or FIRED!) along with their over-time pay.

  1. Assume the following: all the lowercase letters have numeric values 97 through 122, i.e. a=97, b=98, ... , z=122; all the uppercase letters have numeric values 65 through 90, i.e. A=65, ... , Z=90; a special character called the "null character", Ø, has value 0. A word is a contiguous string of non-null letters followed by the null character,Ø. Words are read left to right. Define the lexicographic difference of two words, W1 and W2, to be zero if W1 is identical to W2, otherwise it is the absolute value of the numeric difference of the two letters of W1 and W2 where they first disagree. Examples: W1 is aligator and W2 is alignment so Lex-dif is 13 since n(110) - a(97) = 13. W1 = Align and W2 = align so Lex-dif is 32 since a(97) - A(65) = 32. W1 is bob and W2 is bob so Lex-Dif = 0 since they are identical. W1 is Frank and W2 is Frankenstein so Lex-dif is 101 since e(101) - Ø(0) = 101.

  2. Write an algorithm to compute the lexicographic difference of two words.

To submit this homework, you are going to use the cssubmit program for your section of cs1570. This assignment will be used for all sections. Your answers should be written up using your favorite editer in a subdirectory called hw1 hanging off your cs1570 subdirectory. Remember: make a different directory under cs1570 for every one of your assignments. From that directory, at the UNIX command, type "cssubmit 1570 a 1" if you are in section a. If you are in section b, type "cssubmit 1570 b 1". If you are in section c, type "cssubmit 1570 c 1", etc. (Can you see the pattern?) Hit enter. Of course, when submitting homework #2, your last entry in that command should be a 2. Don't type cssubmit 1570 a h2 or some other variant like that; just the digit 2. Use this scheme for subsequent submissions. If you have any questions about using the editor or submitting, just ask. You can look here for guidance on submitting using the cssubmit command.

NOTE: You can submit the same assignments multiple times. If you submit and then remember something you forgot, you can edit your file, save it, then submit again. The new submission will overwrite the old; we won't see the old one. Time stamps on submissions apply to the latest submission. Always run the submit script from the directory in which the file(s) to be submitted reside(s). Any questions, just ask. Remember, there is a due date/time. Try not to exceed that.