Lab goal: practice reading simple Java code and making minor changes. Introduce algorithms and practice problem-solving.
Get Ready
Create a new subdirectory of csci151 called facts.
Download Facts.java into the facts subfolder/directory. Always save first and then open.
As demonstrated in class, bring up a command window, change directories as appropriate, compile and run Facts. See your notes or lab1 to remember how all this is done.
Open Facts.java with JEdit to edit the code.
Add a new fact
Add a comment in the file that indicates the new code you will be adding. Keep the existing code separate from your new code.
Add a numerical fact of your own choosing that includes concatenation in the print statement. Note that this should be a new fact, not a replacement of one that's already there. Save the file with the same name.
Compile and run the new version of Facts.java.
Algorithms
Read the information at https://runestone.academy/runestone/static/thinkcspy/GeneralIntro/Algorithms.html
Modify your Facts.java file so that it shows the answer to the two questions in the reading.
Show your results and the code. Thus, you do not need to email this file.
Work with variables
Download Geometry.java and save it in a new folder. Always save first and then open. If you do things the other way around the file will have the wrong name.
Compile and run the program as usual.
Look at the code, particularly noting the use of the variable numSides.
Add code that uses a new variable, numPolySides, to print out a new geometrical fact.
Finish
E-mail the new Geometry.java file to garrisonc@winthrop.edu . Include with your submission the cropped command window screenshot showing your results. Be sure to use the standard subject line: CSCI 151, Lab Time, Specific Subject, Student Name.
Verify in your sent folder that you sent the message. If you ever need to resend an assignment include the complete requirements in a single email.