Lab goal: Make sure you can
log into the system, send email, work with Java files, practice problem-solving
and provide information about yourself. Therefore...
I.
Problem-Solving
Partners will practice
problem solving with two of the following problems listed below. So, find a new
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. You will report on your results in the next section. ** Important, only
spend about 10 minutes per problem.
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 mothern-law. But not as many
people attended as it sounds.
How many attended the
reunion?
II.
E-Mail and
Results (Each individual will submit)
1.
Send an email to garrisonc@winthrop.edu
that includes
A. The standard subject line: CSCI 151, Lab Time, Specific Subject, Student
Name(s).
§
Ex: CSCI151_2:00_Lab1__FirstName LastName
B. The preferred name you would like us to use to address you.
C.
A very short reflection on the paired problem solving activity. Who was your
partner? What problem did
you discuss? Did you get the answer? What was your answer? What was it like to
work with a partner?
D.
Your computer experience. As a user, e.g., games, word processing. As a
programmer, e.g. Java, Visual Basic, C++. Whatever you have if any.
E.
Your Interests. Tell me something that will help me remember you.
III.
Java (completed individually)
1.
Make a directory on your Z drive for all the work you will do in this class. I
recommend calling it csci151. If you're not sure how to do this, start by
double clicking on the Z drive icon on your desk top and then click to add a new
folder.
2.
Create a new subdirectory of your csci151 directory called lincoln.
3.
Download
Lincoln.java into the last subdirectory you created.
·
Note: Save it, do not open
it yet. If you open it first the system assigns a different name to it and that
will mess you up later. If you do this correctly you should see Lincoln.java as
the only file in the lincoln directory. (You may just see the name
Lincoln with a note beside it that it's a .java file. That's good too.)
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 if necessary to get to your Z drive. Just
type z: if you need to do this.
7.
Change directories to get to your lincoln directory.
o
E.g. something like cd csci151\lincoln should work. Or you could do this
in two steps: cd csci151 and then cd lincoln. "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.
Type javac Lincoln.java to compile the code. Note that the upper case L
matters. When you're dealing with Java, you have to be careful of upper and
lower case.
·
Think of Java as a language
that's halfway between what a human can understand and what a computer can
understand. With practice, humans can read and write Java code, thus creating
what you will soon see in Lincoln.java. But the computer speaks a different
language. So javac translates Lincoln.java into code the computer can understand
(but humans can't). This code is stored in a new file called Lincoln.class.
·
Check the csci151/lincoln
directory by typing dir to see the new
Lincoln.class file.
·
Now that that Lincoln.java has been compiled into a java class, it can be run as
a java program.
9.
Type java Lincoln to run the program.
10.
Find the icon for Lincoln.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 Lincoln) 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 me the results.
·
If you do not get to show me your results do the
following:
o
Take a screenshot of your results and submit the screenshot in Blackboard and
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/lincoln directory.
·
https://support.microsoft.com/en-us/help/13776/windows-use-snipping-tool-to-capture-screenshots