Skip to content

Instantly share code, notes, and snippets.

@chyiiiiiiiiiiii
Created January 18, 2016 15:09
Show Gist options
  • Save chyiiiiiiiiiiii/864abb7e8d8d0fdb589f to your computer and use it in GitHub Desktop.
Save chyiiiiiiiiiiii/864abb7e8d8d0fdb589f to your computer and use it in GitHub Desktop.
public class Main {
public static void main(String argv[]) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
for (int i = 0; i < n; i++) {
String ask = input.next();
int index = check(ask);
String[] a = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#","A", "A#", "B", "C", "C#", "D",
"D#", "E", "F", "F#", "G","G#", "A", "A#", "B" };
if (ask.length()==2) {
System.out.printf("%s %s %s", ask.charAt(0), a[index + 3],a[index + 7]);
} else {
System.out.printf("%s %s %s", ask.charAt(0), a[index + 4],a[index + 7]);
}
System.out.println();
}
}
public static int check(String ask) {
switch (ask.charAt(0)) {
case 'C':
return 0;
case 'D':
return 2;
case 'E':
return 4;
case 'F':
return 5;
case 'G':
return 7;
case 'A':
return 9;
case 'B':
return 11;
}
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment