prepare a program which can read input from an input text file and can generate its output in a separate output text file

Ramesh really likes soup, especially when it contains alphabet pasta. Every day he constructs a sentence from letters, places the letters into a bowl of broth and enjoys delicious alphabet soup.

Today, after constructing the sentence, Alfredo remembered that the Cricket World Cup starts today! Thus, he decided to construct the phrase “WORLDCUP”. As he already added the letters to the broth, he is stuck with the letters he originally selected. Help Ramesh determine how many times he can place the word “WORLDCUP” side-by-side using the letters in his soup.

Input

The first line of the input file contains a single integer T: the number of test cases. T lines follow, each representing a single test case with a sequence of upper-case letters and spaces: the original sentence Ramesh constructed.

Output

Output T lines, one for each test case. For each case, output “Case #t: n”, where t is the test case number (starting from 1) and n is the number of times the word “WORLDCUP” can be placed side-by-side using the letters from the sentence.

Constraints

1 < T ≤ 20

Sentences contain only the upper-case letters A-Z and the space character

Each sentence contains at least one letter, and contains at most 1000 characters, including spaces

Example Input:

5

WELCOME TO CRICKET WORLDCUP

CUP WITH LABEL WORLCUP BELONGS TO WORLD

QUICK CUTE BROWN FOX JUMPS OVER THE LAZY DOG

MOVE FAST BE BOLD

WORL THE WORLDCUP

Example Output:

Case #1: 1

Case #2: 2

Case #3: 1

Case #4: 0

Case #5: 1

Hello Mam, I have prepared a java program which reads text from input.txt file and writes the content in output.txt file.

The code contains comments and it is self explanatory.

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileReadWrite {

/**
 * @param args
 */
public static void main(String[] args) {
	
	try {
		
		// I have my file in /Users/irudayaraj/Desktop/input.txt
		
		// File from which text has be read
		
		File objInputFile = new File(File.separator + "Users" + File.separator + "irudayaraj" + File.separator + "Desktop" + File.separator + "input.txt");
		
		// File to which text has be written
		
		File objOutpoutFile = new File(File.separator + "Users" + File.separator + "irudayaraj" + File.separator + "Desktop" + File.separator + "output.txt");
		
		// Creating streams to read and write contents
		
		FileInputStream  objFileInputStream = new FileInputStream(objInputFile);
		
		FileOutputStream objFileOutputStream = new FileOutputStream(objOutpoutFile);
		
		int count;
		
		while ((count = objFileInputStream.read()) != -1) {
			
			objFileOutputStream.write(count);
			
		}
		
		// Closing input and output file streams
		
		objFileInputStream.close();
		
		objFileOutputStream.close();
		
	} catch (FileNotFoundException e) {
		System.out.println("Exception got"+e.getStackTrace().toString());
	} catch (IOException e) {
        System.out.println("Exception got"+e.getStackTrace().toString());
	} 
}

}