In this lab, you will practice using conditional statements and looping constructs in Java.
ReadPrint
Implement a class named ReadPrint
that does the following:
main
read a number from keyboard and
call generateList
with the number.generateList
takes one integer parameter and
generates a list as follows:
Note that I did not even mention that the
class ReadPrint
must be in a file
named ReadPrint.java
because it would be obvious by now. I
won't mention that any more in the future.
SkipPrint
Implement a class named SkipPrint
that does the following:
main
read a positive integer from keyboard
and call skipPrint
with the number. If the number is
not positive, your program should terminate by indicating that
the number was not positive. If positive, then
the main
calls skipPrint
with the number as an
argument.skipPrint
takes one integer parameter and prints
from 0 up to the number but by skipping the multiples of 3 or 5.
For example, if the number was 13, your skipPrint
should
print: 0, 1, 2, 4, 7, 8, 11, 13. Note that 0 may be considered a
multiple of 3 or 5, but I want your function to still treat it as an
exception.
Using Conditionals with Strings
Create a Java class named StringSeparation
that takes in a sentence as input from the user. The program should then
go through the input and pull out the second word in the sentence and print that word. For this problem,
assume each word has exactly one space between every other word and the user always enters at least 3 words.
For example if given:
This example sentence is entered by the user
It would print:
The second word is: example
Use the charAt(index) and substring() String methods to solve this problem.