Course web page: Introduction to Computer Science for non-majors II James Tam Return to the course web page

CPSC 219: Mini-Assignment #1

Due Jan 28 at 4 PM

New Concepts to be applied for the assignment

Aside from the 'main()' method you are not to write static methods for this assignment. (If you don't know what I'm referring to by static methods, I will be discussing this topic later in the course).

Description

 
  • Define one class 'Exponents', your code will be all be contained in the main() method of this class. The file name of course must be called "Exponents.java". (1 mark for class and method definition)
 
  • The program will calculate a number of exponents (user will be prompted to enter a value between 1 and 10 which determines the number of exponents calculated: 1 mark for prompt) which will be stored in an array, each exponent will be stored as a separate array element. (1 mark for storing results in a 1D array)
 
  • For each exponent to be calculated the program will prompt the user for a base and a power (1 mark for prompt) either of which can be any non-negative integer.
   
  • The program can correctly calculate an exponent when the power is zero (the result is just one). (1 mark)
   
  • The program can correctly calculate an exponent when the power is greater than zero. (1 mark)
 
  • The number of exponents calculated should match the value entered by the user. (1 mark)

Marking key

Marks earned 7 6 5 4 3 2 1 0
Grade point 4.0 3.7 3.3 2.7 2.3 1.7 1.0 0

Submitting your work:

  1. Assignments (source code/'dot-java' file) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

Sample program execution

You can find in a text file a sample run of my program in the course directory (/home/219/assignments/mini_assignment1) or view it with the following [link]

External libraries that can be used (unless otherwise told don't use external code).

  1. You cannot use methods other than the ones for input (Scanner class) and output: printf(), print(), println(). Obviously math library methods, such as the ones that calculate an exponent for you, cannot be used.