CMPSCI 121
"Introduction to Problem Solving with Computers" using Java

Department of Computer Science
University of Massachusetts Amherst

Home
Resources
Grading
Weekly Schedule
Syllabus
Homework
Exams

Bulletin Board
Staff

Programming Assignment #2

Due in OWL, 9:00am, Tuesday February 15, 2005.
Extra credit of 5 points if handed in before 11:59pm, Monday February 14, 2005.

Important notes:

  • This programming assignment contains two problems, and can earn a total of 100 points as described below.
  • Extra credit described below accumulates points into an overall extra credit count that may be used at the end of the semester to determine letter grade border cases at the end of the semester.
  • File, class and method names should be exactly as described below. You may, however, if needed add additional helper variables and methods.
  • Each method's return type, as well as the number, order, and types of parameters must be as specified. Parameter names don't have to be the same.

Problem 1: A LemonadeStand Class (50 points)
[Collaboration not allowed]

Incomplete Draft Description. Donald Trump. The Apprentice. First season task: sell lemonade. Lemonade stand with lemons and cash. Construct with given amount of cash. Method sellLemonades(int n) sells n cups of lemonade; lemon count goes down by n, cash goes up by 2n. Method buyLemons(int n) buys n lemons; lemon count goes up by n; cash goes down by 0.5n. No error checking (nothing preventing cash from going negative.) Extra credit 5 points: allow price of lemonade to get set in constructor for LemonadeStand().

Problem 2: A ShoppingList class. (50 points)
[Collaboration not allowed]

Incomplete Draft Description. Make a shopping list by appending to the end of a string, also keep count of the number of items on the list. Methods: addItem(String s), items(), numberOfItems(), clearList(). The method addItem should insert a '\n' between each.