Lab Exam 2 Section 311
Lab Exam 2 Section 311
Lab Exam 2 Section 311
Lab Exam 2
Instructions - Overview
Follow the instructions starting on page 2 of this handout to design a problem solution, create a Java program, and
test your program. Documenting each part using an MS Word document.
This exam must be completed and submitted by the end of your lab period.
Note: Each lab section will be given a unique problem statement to help detect cheating.
Pseudocode
Screen shots of program execution
Page 1 of 4
From Lab Exam 1 (Reference and Starter Code)
In Lab Exam 1 you would have created the following class (or similar), a starting code file to be used is provided.
Length is in centimeters, litresPerCm is litres per centimeter.
AquariumFish
-fishLength:double
-litresPerCm:double
+AquariumFish()
+getFishLength():double
+setFishLength(fishLength:double):void
+getLitresPerCm():double
+setLitresPerCm(litresPerCm:double):void
+calculateLitresNeeded():double
A client would like a menu-driven application that runs until an exit-AquariumFish option is selected. The other
two menu choices should be edit- AquariumFish and print- AquariumFish. If edit is selected, the fields should be
updated by interacting with the user to get values and setting them into the object. If print is selected, the result
of calculateLitresNeeded() method should be displayed. If exit is selected, a message, “program exits” is output
and the program shuts down. If any other number is entered as a menu choice, the program should display a
message “invalid menu input” and then continue running.
Output the menu options directly in method main, each time the loop repeats, with your full name.
Use the following constants inside method main for forming the menu outputs, as well as for the logic of the
program
EDIT_AQUARIUM_FISH with value 1
PRINT_AQUARIUM_FISH with value 2
EXIT_AQUARIUM_FISH with value 3
You are not required to validate inputs from the user that would crash the program. Assume that the user will
only enter numbers with the correct data-type as needed for demonstrating the running program.
Using this class with a method main, follow your pseudocode to create the working program.
Use Java coding conventions for identifiers: class, constructor, field, variable, and method names
Comment your code for this file only, as requested and demonstrated in the course.
Page 2 of 4
Part 3 Test the Program with Screen Shot(s)
Use the following test actions in creating screen shots of your running program; you may demonstrate more than
one test in a single screen shot.
o Option for editing the fields input, with input for each field.
o Option for printing report input, with output displayed
o Invalid option for exit program, output message and program should continue
o Option for exit program.
See the sample run of the program as reference.
Page 3 of 4
Grading (10 Points)
Criteria Missing / Poor (0) Below Expectations (1) Meets Expectations (2)
Pseudocode Missing or incorrect Pseudocode is included in Pseudocode is included in
MS Word document, MS Word document,
however there are logic provides a working
mistakes and-or missing algorithm that meets the
the loop and-or the requirements.
selection structure(s).
Screen shots executing program Missing or incorrect Screen do not demonstrate Screen shots demonstrate
or missing students all of the requested menu the use of the menu
full name in the options, or the program options; the program does
output. crashed when receiving not crash when receiving
acceptable numerical acceptable numerical
input(s). input(s).
.java files: comments and Missing or incorrect. Java coding conventions for Java coding conventions for
conventions identifiers, indentation are identifiers and indentation
not fully followed. are fully followed.
.java file with method main .java file with method main
contains some programmer contains comment header
comments but missing with format specified for
information or incomplete. course. Each class and
method has a comment
above the header with a
brief statement about the
class or method.
.java files: syntax Missing or incorrect. Class file(s) may have small Class file(s) do not have
syntax mistakes that would syntax mistakes and should
prevent them from compile.
compiling
.java files: logic in method main. Missing or incorrect. Logic for the specified class Logic for the specified class
within method main not within method main is
correct. correct and meets
requirements.
Page 4 of 4