L01a
Due by the end of this meeting
SUBMIT
/
Submission Summary
Review of CSCI 1226
Create a program called A01Prep.
its main method should be as follows:
// activity 1
int size = getNumFoods();
System.out.println("You said you had " + size + " foods.");
// activity 2
String[] words = {"One", "Two", "Three", "Four", "Five", "Six", "Seven"};
printShortWords(words);
- Activity 1
-
Write the
getNumFoods
method.
Make it behave as the javadoc comment in A01 says:
/**
* Read the number of foods from the user. The number must be positive. The
* method continues to prompt for input until a positive number has been
* entered.
*
* @return a positive integer indicating how many foods the user has
*/
- Activity 2
-
Write the
printShortWords
method.
This method asks the user for the longest word they'd like to see,
and then the method goes thru the array it was given,
printing the words that are that length or less.
For example,
How many letters in the longest words to show: 4
Here are the words of 4 or less letters:
One
Two
Four
Five
Six
If the number the user enters is negative,
the program instead prints out an error message.
How many letters in the longest words to show: -1
That doesn't make any sense!
Submit your program
by the end of this recitation.
Your grade will be based on the following rubric:
- 0 points: it does not compile;
or does neither activity is complete and correct;
or either activity uses methods or controls not covered in csci1226.
- 1 point: one of the two activities is complete and correct;
or both activities are complete and correct
but the program style is incorrect.
- 2 points: both activities are complete and correct,
and the program uses correct style.
Submit this/these files:
SUBMIT
/
Submission Summary