Problem Solving Assignment 1(b)



Due Tuesday, January 16, midnight



This work should be done in it's own directory. (see Details section below)

This homework requires skills from Chapter 1 and Chapter 2.

You have been hired to work at the Krusty Krab restaurant. Your boss, Eugene Krabs, wants you to write a program to run calculations to help with planning ingredients and prices for the restaurant. Write this program in a file called KrustyKrab.java. Your program should do the following things (in order):

    1. Prompt the user to input (type on the keyboard) the number of ounces of Seahorse meat they have, as a whole number. Save this into an integer variable called ozSeahorseMeat. See pg. 81 of the book for an example of good style for the message you give the user telling them what to do.

    2. Output the number of Krabby Patties that can be made using the Seahorse meat the restaurant currently has. It takes 4 oz of Seahorse meat to make one Krabby Pattie (just for fun: see the Krabby Pattie Secret Recipe here). Remember: nobody wants a partial Krabby Pattie, so the number you output should be an integer representing only the number of complete Krabby Patties that can be made.

    3. Prompt the user to input two whole numbers separated by space(s): the number of dollars spent on potatoes for Krabby Fries this month, and the number of servings of Krabby Fries that can be made from those potatoes (again, see pg. 81 of the book). Save these into integer variables called friesExpense and friesServings.

    4. Output the price that the restaurant should charge per serving of Krabby Fries to “break even” (no profit, but not lose money either). This should be a floating point value, because Mr. Krabs wants to know as close as possible to the exact amount (it is ok that more than 2 decimal places are printed out--in other words don't worry that the answer may include fractions of a penny).

After you get the program to compile with no errors, you should test it with many different values. Trade test cases with others on the WebBoard!


Details

  1. Start by creating a directory (folder) in your ieng6 cs8fzz account (using this directory will make the turnin script run smoothly too). After you log in, create a directory by typing the command (don't type < enter > just hit the key) :

      mkdir psa1 < enter >

    Go into that directory (like double clicking to open a folder) with the command:

      cd psa1 < enter >

    You MUST name your directories (folders) and files as indicated in the problem descriptions. Otherwise, the turnin program may not work.


  2. UPDATE 1/12/07: To help you get the idea of what your program is doing, here is an example of what it might look like:
    -bash-2.05b$ java KrustyKrab
    Welcome to KrustyKrab-O-Matic. 
    Please enter number of ounces of Seahorse meat on hand: 
    5
    Krabby Patties use 4oz. of Seahorse meat each, so you can make 1 Krabby Patties.
    Please enter dollars spent on potatoes this month, and servings of Krusty
    Fries they can make (separated by one or more spaces): 
    4 3
    To break even, charge $1.3333334 per serving of Krusty Fries.
    -bash-2.05b$ 
    
    The blue stuff is what the user types in. The "-bash-2.05b$" thing you should recognize as the thing that always comes before your cursor when you are in UNIX on ieng6 (it is called a "prompt" because it is sort of prompting you to type a command). NOTE: Your wording does not need to be exactly the same. Just as long as you tell the user what to type, and what the answers are, in a reasonable way, that's fine if you don't use the exact same wording and format that I did.

  3. Hints to make your life easier:

Grading

This assignment is worth 5 points:

How to turnin your homework electronically

When you are ready to turn in your homework, run bundle-psa1 from your psa1 directory. The session should look like this:

-bash-2.05b$ cd ~/psa1
-bash-2.05b$ bundle-psa1
Good; all required files are present:

        KrustyKrab.java

Do you want to go ahead and turnin these files? [y/n]y
OK.  Proceeding.


Performing turnin of approx. XXXX bytes 
Copying to /home/linux/ieng6/cs8f/turnin.dest/cs8fzz.psa1
.
Done.
Total bytes written: XXXX 
Please check to be sure that's reasonable.
Turnin successful.

If you want to make changes after you've turned in your homework, make the changes and run bundle-psa1 again. The program will warn you that a "previously turned-in file exists" and ask if "you wish to over-write this existing file" (delete the old version and replace it with this new one). Respond in the affirmative by typing y and pressing the Enter key.


Learning to use text editors

Vim
Run vimtutor, a separate program that will teach you to use Vim.
Emacs
Use the built-in tutorial by running emacs and, within the editor, typing CTRL-h t.

Which editor should I use?

For most of us, the choice of a text editor is a matter of preference (or, more likely, familiarity). It happens that Beth Simon and Cynthia Lee use Vim, but many other computer scientists use Emacs. Both may seem hard at first, and both will become second nature with practice. So, in that sense, it doesn't matter which one you choose.