The Question
Write a java program called Q1.java that will do the following:
prompt for and read in a positive integer n.
Output, alone on a line, the sum of the cubes of the integers
from 1 to n inclusive.
For example, if 5 is entered, the output should be 225
(which is equal to 13 + 23 + 33
+ 43 + 53). You may assume that the input
is well-formed, i.e. that it is indeed a positive int. And you may
assume that the sum to be output can also be represented as an int.
The output should conform to that in the sample runs of a correct program
shown below.
Note that, in these sample runs, the % sign is not part of the program output.
User input is shown on the same line as the prompt.
Sample Runs
% java Q1
Enter a positive int ... 1
1
% java Q1
Enter a positive int ... 3
36
% java Q1
Enter a positive int ... 5
225
%
Useful APIs
Here (again) are the common APIs
that you may access:
Java 1.5 API
Type API
Submitting Your Work
Here is the command to submit your work
(further details regarding the submit command can also be
obtained by
typing man submit
Once again, you are encouraged to submit
regularly.
Newer submissions overwrite older ones.
submit 1020 exam Q1.java