Created
October 11, 2017 21:43
-
-
Save viveknarang/bb81be6cc333e9f73850cfc8e1e3caf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.codec.binary.StringUtils; | |
public class E2C { | |
public static void main(String args[]) { | |
String input = "DA-AC-C+DDAFB+"; | |
int am=0; | |
int a = 0; | |
int bp = 0; | |
int b = 0; | |
int bm = 0; | |
int cp = 0; | |
int c = 0; | |
int cm = 0; | |
int d = 0; | |
int f = 0; | |
for(int i = 0 ; i < input.length()-1; i++) { | |
if (input.charAt(i) == 'A' && input.charAt(i+1) == '-') { | |
am++; | |
} else if (input.charAt(i) == 'A') { | |
a++; | |
} else if (input.charAt(i) == 'B' && input.charAt(i+1) == '+') { | |
bp++; | |
} else if (input.charAt(i) == 'B' && input.charAt(i+1) == '-') { | |
bm++; | |
} else if (input.charAt(i) == 'B') { | |
b++; | |
} else if (input.charAt(i) == 'C' && input.charAt(i+1) == '+') { | |
cp++; | |
} else if (input.charAt(i) == 'C' && input.charAt(i+1) == '-') { | |
cm++; | |
} else if (input.charAt(i) == 'C') { | |
c++; | |
} else if (input.charAt(i) == 'D') { | |
d++; | |
} else if (input.charAt(i) == 'F') { | |
f++; | |
} | |
} | |
System.out.print("A :"); | |
for (int i = 0 ; i < a; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("A- :"); | |
for (int i = 0 ; i < am; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("B+ :"); | |
for (int i = 0 ; i < bp; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("B :"); | |
for (int i = 0 ; i < b; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("B- :"); | |
for (int i = 0 ; i < bm; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("C+ :"); | |
for (int i = 0 ; i < cp; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("C :"); | |
for (int i = 0 ; i < c; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("C- :"); | |
for (int i = 0 ; i < cm; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("D :"); | |
for (int i = 0 ; i < d; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
System.out.print("F :"); | |
for (int i = 0 ; i < f; i++) { | |
System.out.print("-"); | |
} | |
System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment