CMPS 260 Programming Assignment #3 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Assignment Description
1. First, create an Intellij Java project and name it “pa3_your-id”.
2. Create a normal (POJO, JavaBean) class to represent, i. e. model, varieties of green beans (also known
as string beans or snap beans). Following the steps shown in “Assignment: Tutorial on Creating Classes
in IntelliJ”, create the class in a file of its own in the same package as class Main. Name the class an
appropriate name. The class must have
(a) private field variables of appropriate types for variety, pod length and number of seeds in the pod.
Variety must not be set to empty. Pod length must be set to a value greater than zero. The number of
seeds in the pod must be zero or greater.
(b) a public getter (accessor) and setter (mutator, manipulator) for each private field variable. The
getters must not have parameters. The setters must have only one parameter.
(c) a public default constructor, i. e. a constructor without parameters.
(d) a parametrized constructor, i. e. a constructor with parameters, one parameter for each of the private
field variables.
3. In the class Main,
(a) create a void method that when passed an array of green bean class type, outputs the information
about each green bean object referenced by the elements of the array passed to the method. If an
element of the array has the value null, nothing is output for that element.
(b) Create a method that when passed an array of green bean class type, returns the average length of the
pods of the beans referenced by the elements in the array. Be sure to not count or try to get data from
the elements or the array that have the value null.
(c) Create a method that when passed an array of green bean class type, returns the average number of
seeds in the pods of the beans referenced by the elements in the array. Be sure to not count or try to
get data from the elements or the array that have the value null.
CMPS 260 Spring 2019 Programming Assignment #3 (2019.02.19) 2
4. In method main of class Main,
(a) create an array of your green bean class type that can hold 10 elements of green bean class type, then
assign
i. a unique object of green bean class type to 7 of the elements, each object of a different variety.
Some green bean varieties are string bean, filet beans, long beans, purple string beans, flat beans,
wax beans and bush beans.
ii. null to the remaining elements with the proviso that null cannot be assigned to adjoining
(neighboring) elements.
(b) Call the three methods created in step #3, passing each the array create above and output the values
returned from the non-void methods.
(continued on the next page)
CMPS 260 Spring 2019 Programming Assignment #3 (2019.02.19) 3
Additional Requirements
(a)A reference variable and instance object of class java.util.Scanner must be used to read the input from the
user. Prompts for user input must be clear and relevant.
(b)Output to the user must include appropriate labels.
(c)Identifiers must be descriptive, i. e. must self document. The only exception granted is in the case of a
“for variable”, that is a variable created as a simple counter as in the control variable in a “for” loop
statement.
(d)Indention of all code blocks (compound statements, anything in braces), including single statements
following selection or while statements, is required.
(e)The main “.java” file [the one with the method public static void main(String[] args)] of your Intellij
projects must contain this minimal documentation as the first lines of the file (i. e. above the package
statement):
// Your Name
// Your ID
// CMPS 260
// Programming Assignment : #
// Due Date :
// Program Description: (a brief description of actions of your code)
// Certificate of Authenticity:
(Choose one of the two following forms:)
// I certify that the code of this project, other than that that was generated by Intellij, is entirely
// my own work.
{or}
// I certify that the code of this project, other than that that was generated by Intellij, is entirely
// my own work, but I received some assistance from {name}. Follow this with a description of
// the type of assistance. (For example, if you consulted a book, and your solution incorporates
// ideas found in the book, give appropriate credit; that is, include a bibliographical reference.)
// Note: You do not have to list the text, the author of the course text or the instructors examples.
Submitting
In Intellij, select File, Save All, then select File, Export to Zip File and click OK to save the Zip archive
file. Finally, upload the zip archive file to Moodle.
Helpful Hint: Keep a backup copy of your project folder on a Google Drive, a Drop Box Account, a USB
memory device, etc., or even on Moodle! Finally, once you turn in your final version, create a copy
before the due date and do not change this copy in any way. This final copy can be consulted if there is
an upload disaster, but only if the “.java” files have not been changed in any way after the due date.