Hey I'm new here and I am currently learning java in school
I have a few questions?
one my teacher wants us to write a program that has you read a few words from a text file and output it in another file in title case form
so I wrote
public class Hw7
{
public static void main(String args[])
throws FileNotFoundException
{
Scanner inFile =
new Scanner(new FileReader("Raw.txt"));
PrintWriter outFile = new PrintWriter("processed.txt");
String one;
int words = 1;
while (words < 20)
{
one = inFile.next();
one = one.substring(0,1).toUpperCase() + one.substring(1).toLowerCase();
outFile.print(one);
words = words + 1;
}
inFile.close();
outFile.close();
But apparently its not working.
there are only nine words in the text and I know I can make a seperate string for each one but that would be stupid.
Instead I wanted to use one string and repeat it until it got through all of them.
I was trying to be smart...
please help