Lab Exam 2 Section 311

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

CST8116 Lab Exam 02 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.

Instructions – Submission Notes


 Upload your MS Word document, as well as your Java source code files (.java files) to Brightspace by the end of the
lab period.
 You are not required to copy source code into your MS Word file, however your .java file(s) must be uploaded.
 Your lab professor may specify additional submission requirements in the lab period.

Instructions – Open Book Exam


 This is an open book lab exam; you may use your textbooks, lecture notes, exercises, assignments, hybrids for help.
 You are not permitted to talk to, or chat with other students during the lab exam.
 You are not permitted to talk about, or share materials from, your lab exam, with students in other lab sections.

Instructions – Appropriate Use of Zoom during Exam


 To get help from the professor raise your hand (virtually) using Zoom, or send a private chat to your professor. Your
professor will assign you to a break out room where they can join and then help you (verbally talk and or you may
share your screen).
 Please, do not un-mute your microphone and verbally ask questions in the main Zoom session, it is disruptive to
other students.

Instructions – Microsoft Word Document Format


Suggested Headings (See template provided)

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

Lab Exam 2 Tasks


Part 1 Pseudocode
 Write the Pseudocode for a main method that would perform the following tasks, you will need to use a
repetition structure (a loop), and a selection structure (if or case) and some constants.

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.

Part 2 Write the Java code for the class


 Create an Eclipse Project named FullName_LabExam2_SectionNumber
o For example, a student with first name “Abc” and last name “Xyz” in section 123 would name the project as:
AbcXyz_LabExam2_Section123

 Create a class with method main. Name the class as FullNameLabExam2SectionNumber


o For example, a student with first name “Abc” and last name “Xyz” in section 123 would name the class as:
AbcXyzLabExam2Section123, with resulting file name AbcXyzLabExam2Section123.java

 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.

Sample of expected program execution.


Enter Option:
1 to edit fish
2 to show litres needed
3 to exit program
Program by Stanley Pieda
1
Enter Fish length CM: 2
Enter litres per CM: 4
Enter Option:
1 to edit fish
2 to show litres needed
3 to exit program
Program by Stanley Pieda
2
8.0
Enter Option:
1 to edit fish
2 to show litres needed
3 to exit program
Program by Stanley Pieda
900
invalid menu input
Enter Option:
1 to edit fish
2 to show litres needed
3 to exit program
Program by Stanley Pieda
3
program exits

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

You might also like