CSE101 Assignment 03

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

CSE 101 Programming Assignment 3 Page 1 of 4

Due:
4-December-2022 by 23:59

Deliverables:
The following Java file should be submitted to Google Classroom by the due date and
time specified above. Submissions received after the deadline will be subject to the
late policy described in the syllabus.
o StoreUsingArrays_{StudentNumber}.java
Specifications:

Overview: You will continue the program this week to maintain the inventory for a store. Do
not forget your headers with @author and @date information. This program will be
expanded in future weeks, so be sure you understand the concepts covered in this program.

Requirements: Write a program that will simulate the user interface for a store. It will
take arrays as parameters for the starting inventory. Then will ask the customer to
request items, show a total, take a payment from the customer and display the change
total.
To facilitate the execution of this program, you will write (at minimum) the following
methods:
1. menu(item, price, input)
a. A new method to display the options based on the contents of the arrays
b. Takes an array of strings and an array of decimal numbers as parameters
c. Displays to the output each of the name and price of each item in the
arrays preceded by a consecutive number ending with “0 - to checkout”
d. Gets the choice from the user and returns it
e. Returns integer

2. returnedAmounts(amount)
a. A method to determine the type of bills and coins to be given
b. Takes one parameter for the amount to be given
c. Returns a String containing the number of each type of bill in the format
of “# - Type” (i.e. “2 – 20”, “3 – 1”), each on a separate line.
i. The values tested will be standard TL types (200, 100, 50, 20, 10, 5,
1, 0.50, 0.25, 0.10, 0.05, 0.01)
d. Only show the TL amount if that type should be part of the change given.

CSE 101|Fall 2022 1


CSE 101 Programming Assignment 3 Page 2 of 4

3. storeRun(item, quantity, price)


a. A method to run the store program
b. It will take three parameters
i. String array for names of the items in stock
1. For each item in this array it will change the name to
capitalize the first letter and lowercase other letters
ii. Integer array for number of each item
iii. Decimal array for price of each item
c. It will run according to the description above until the user types “0” for
the prompt.
d. NOTE: This method will use much of the main method from your previous
assignment
e. Returns None
4. capitalizeString(text)
a. Format text with the first letter uppercase; all other letters lowercase
b. Takes a single String as a parameter
c. Returns another String formatted as described
5. capitalizeArray(name)
a. For each value in the name array, format name with the first letter
uppercase; all other letters lowercase
b. Takes an array of Strings as a parameter
c. Returns none
d. Note: You can call your capitalizeString method from this method

6. Any other methods you feel helpful can be implemented, however, these will be
the only methods tested.

Design:
When storeRun() is called, your program should display the list of items and prices to
the customer and ask what he/she would like to purchase. When the customer decides
to checkout, the total will be shown and the amount given will be entered. If the amount
is enough, the change will be given and the remaining amounts will be displayed. The
customer should be able to add more items of a given type (i.e. the customer may decide
to buy more of something).
The example on the next page was executed using the following code:

CSE 101|Fall 2022 2


CSE 101 Programming Assignment 3 Page 3 of 4

Note: The code above was a main method used to execute the store program. You are
not required to have a main method. You are encouraged to use a main method to test
your store program. If you include a main method, it will not be used for grading
purposes.

CSE 101|Fall 2022 3


CSE 101 Programming Assignment 3 Page 4 of 4

If the customer enters an invalid choice or invalid amount requested, the program
should display an error message. Also, the program should keep asking for an amount
given until a total that is greater than or equal to the total is entered. Examples shown
below:

Code: Create variables for the various values entered by the user and assign it using the
Scanner object. As a user enters valid values update the values of the variables
accordingly.

Test: You are responsible for testing your program. It is important to not rely solely on
the examples presented in this Project description.

Grading:
MS Teams Submission: If anything is ambiguous, it is your responsibility to ask questions. It
is also your responsibility to complete this assignment in a timely manner. E-mails with
questions regarding this assignment will likely not be answered if received after 17:00 on the
last weekday before the due date of the assignment. You can submit multiple times,
however, we will only grade the last version that you submitted.

NOTE: If you use System.exit() in your code, you will automatically receive 0 points for this
assignment.

Filename: You must name your java file according to the description above. If your file is not
named in this way, your submission for this assignment will not be accepted.

CSE 101|Fall 2022 4

You might also like