Convert from java into C++.. Give me the c++ code.. Help me..



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
  public class CountCurrecy {
	/**
	 * @param args
	 */
	public static String[] numWords = { "One", "Two", "Three", "Four", "Five",
			"Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve",
			"Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen",
			"Eighteen", "Nineteen", "Ten", "Twenty", "Thirty", "Fourty",
			"Fifty", "Sixty", "Seventy", "Eighty", "Ninety", "Hundred",
			"thousand" };

	public static String file = "hkj ;ldsf akf; las dkf ;ldff thousand nine hundred twenty three k;sjdf, asldkfjs. lsakdfasdjf five hundred twenty three dksjlakfsd df sdaff. 89: eighty nine 8989: eight thousand nine hundred eighty nine.";

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		boolean isContinue = true;
		boolean isEnd = false;
		int count = 0;
		int startPos = 1;
		int endPos = 0;

		String fileWords[] = file.split(" ");
		String[] outputFile = fileWords.clone();
		for(int k=0; k<fileWords.length ; k++){
		outputFile[k] = fileWords[k];
		}

		for (int i=0; i< fileWords.length ; i++) {
			if (check(fileWords[i])) {
				if (isContinue) {
					System.out.print("\n" + fileWords[i]);
					startPos = i;
					count++;
					isContinue = false;
				} else {
					endPos = i;
					isEnd = true;
					System.out.print(" " + fileWords[i]);
				}
			} else {
				if(isEnd){
					for(int j = startPos ; j<=endPos ; j++){
						outputFile[j] = "";
						if(j==endPos)outputFile[j]="#";
					}
				}
				isEnd = false;
				isContinue = true;
			}
			for(int j = startPos ; j<=endPos ; j++){
				outputFile[j] = "";
				if(j==endPos)outputFile[j]="#";
			}
		}
		System.out.println("\nCount" + count);
		System.out.println("\n\n\t\tOutput File\n");
		for(String word : fileWords)
			System.out.print(" "+word);
		System.out.println("\n\n\t\tOutput File\n");
		for(String word : outputFile)
			if(!word.equals(""))
				System.out.print(" "+word);
	}

	public static boolean check(String fileWord) {
		for (String numWord : numWords) {
			if(fileWord.charAt((fileWord.length() - 1)) == '.');
				if(numWord.equalsIgnoreCase(fileWord.substring(0, (fileWord.length() - 1))))
					return true;
			else if (numWord.equalsIgnoreCase(fileWord)) 
				return true;
		}
		return false;
	}

}
How about you attempt this, then post a question when you run into a problem? We aren't doing your work for you
Learn C++ by yourself, not asking to convert a programming language's code into another.
Topic archived. No new replies allowed.