Lab 1 alternate: The Calculate Game

OBJECTIVES

To begin thinking about efficiency and to review Java program design.

BACKGROUND

For her birthday, Dr. Parks gave Dr. McRae the game Einstein Brain Station, by Excalibur Electonics, Inc. It comes with a large variety of games, one of which is a simple game called "Calculate." We will play this game in class, read the directions that come with the game, and talk a little about it.

ASSIGNMENT

Your job is to write a program that solves the game. Your version should be able to take as input a list of 6 different numbers (from 1 to 19) and a goal value, and determine a sequence of arithmetic operations: addition, subtraction, multiplication, and division (operations performed left to right) to reach that goal and display the calculation giving the result, or declare that it is impossible. No partial result of the arithmetic (assuming one begins calculating left to right) can go negative (although zero is fine), and all partial results must be whole numbers (all division must yield remainders of zero), and no partial result may go higher than 10000.

Later we will discuss the efficiency of our algorithms for this program, looking at how the time of the program changes as the data size increases. A data size increase might refer to the number of numbers in the number list. It might relate to the size of the largest number allowed. It might relate to the maximum value of a partial result. A program that earns a grade of A will all allow these values to change (either make them constants, or values that can be input to a class/program.)

A nice input format and a nice output format are always appreciated, but the emphasis of the program is on getting a program that can compute the goal efficiently (or at least in a time that is reasonable for a listsize of 6, max value of 19, and max result of 10000.) Put your efforts here first: make sure you have a reasonable input format and output format, and then add the bells and whistles if you have time. Bells and whistles are impressive only when the main objectives of the assignment are met.

EXAMPLES:

Enter your number list:
2 5 11 16 17 18

Enter goal:
1527

My solution:
2 + 17 * 5 * 16 + 18 - 11   = 1527
java Calculate
Enter your number list:
5 6 9 11 12 13

Enter goal:
192

My solution:
5 + 9 * 13 - 6 * 12 / 11   = 192

DELIVERABLES

Submit your program by 11:55pm on January 27th on AsuLearn.

GRADING

Your program will be graded on the following: