Lab goal: practice problem-solving and pseudo-code.

 

I.                 Problem-Solving

  1. Partners will practice problem solving with two of the following problems listed below. Find a partner, choose two of the problems to solve and then solve the problems using the techniques discussed in class. Make sure to alternate your roles for each problem. ** Important, only spend about 10 minutes per problem.

  2. Report on your results by email.  Give a short reflection on the paired problem solving activity.

    1. Who was your partner?

    2. What problem did you discuss? Did you get the answer?

    3. What was your answer?

    4. What was it like to work with a partner?

Problem List 

1.   Broccoli and peas for lunch:
When Adrian, Buford, and Carter eat out, each orders either broccoli or peas. If Adrian orders broccoli, Buford orders peas. Either Adrian or Carter orders broccoli, but not both. Buford and Carter do not both order peas.

 

Assuming that the three ate out, who could have ordered broccoli and who could have ordered peas?

 

2.   The Fox, the Goose, and the Corn:

A farmer with a fox, a goose, and a sack of corn needs to cross a river. The farmer has a rowboat, but there is only room for only the farmer and one of his three items. Unfortunately, both the fox and goose are hungry. The fox cannot be left alone with the goose, or the fox will eat the goose. Likewise, the goose cannot be left alone with the sack of corn, or the goose will eat the corn. How does the farmer get everything across the river without getting any of the items or himself wet?

 

3.   The Woman Freeman will Marry:
Freeman knows five women: Ada, Bea, Cyd, Deb, and Eve.
1. The women are in two age brackets; three women are under 30 and two women are over 30.
2. Two women are teachers and the other three women are doctors.
3. Ada and Cyd are in the same age bracket.
4. Deb and Eve are in different age brackets.
5. Bea and Eve have the same occupation.
6. Cyd and Deb have different occupations.
7. Of the five women, Freeman will marry the teacher who is over 30.

Whom will Freeman marry?

 

4.   The Round:

Anthony, Bernard, and Charles played a round of card games, each game having exactly one winner.

1. The player who first won three games was to be the winner of the round.

2. No player won two games in succession.

3. Anthony was the first dealer, but not the last.

4. Bernard was the second dealer.

5. The players sat in fixed positions around a table, with the player on the current dealer's left being the next dealer.

6. No player who was the dealer for a game won that game.

 

Who won the round?

 

5: Family Reunion:

A family reunion was attended by the following people: one grandfather, one grandmother, two fathers, two mothers, six children, four grandchildren, two brothers, two sisters, three sons, three daughters, one father-n-law, one mother­n-law. But not as many people attended as it sounds.

 

How many attended the reunion?

 

II.        Java (completed individually)

    1. Open the command shell

4.   At the bottom left of the keyboard find the <windows> key. It's the one with the little flag on it. Press <windows><r>

5.   In the space provided type cmd. This will bring up a black "command shell"

6.   In the command shell change drives to get to your Z drive. Just type z: if you need to do this.

7.   Change directories to get to your quote directory.

o    E.g. something like cd csci151\quote should work. Or you could do this in two steps: cd csci151 and then cd quote. "cd" stands for "change directory". If you type dir (for directory) you'll see the same files in the command shell as you saw graphically before.

8.   Recall  javac Quote.java to compile the code. Note that the upper case Q matters. When you're dealing with Java, you have to be careful of upper and lower case.

9.   Recall java Quote to run the program. Run it now to see the output again.

10.                     Find the icon for Quote.java, right click and select "open with JEdit" to edit the file. It may take a few seconds, but it will come up. Look it over. What does "System.out.println" do?

11.                     Change the code so that it presents a quote by you (instead of Solomon) and then change the quote. Save your changes into the same file.

12.                     Compile and run your new program. Any time you make a change to a program you must save and recompile it (using javac) before you can run it (using java) to see the differences.

13.                     Show the results.

Creating an image for submitting your work.

Take a screenshot of your results and submit the screenshot by  email as an attachment. Note, only include a picture of your command shell (not the entire monitor screen). How you obtain a screenshot of the command shell is up to you as long as you use software on the computer that is currently sitting in front of you. You might consider using:

·       The PrtScn button in combination with MS paint to crop the image.

·       Snipping tool

·       Press windows key (bottom left on keyboard), search for snippet then open, drag a box around the command shell, save it into your csci151/quote directory.

·       https://support.microsoft.com/en-us/help/13776/windows-use-snipping-tool-to-capture-screenshots

 

 III. Purchase your textbook if you have not already.  Programming in Java. Sign in or create an account at zyBooks.com. Enter zyBook code. This book is required and will be used for readings and to complete at least 30% of the course grade.Complete required reading and activities before next class.