public class Tests {
public static void main(String[] args) {
//long start = System.nanoTime();
System.out.println(note("B", "Ti"));
//long end = System.nanoTime();
//System.out.println(end - start);
}
private static String note(String majorScale, String note) {
String[] notes = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "B"};
int base = 0;
int shift = 0;
int result = 0;
switch (majorScale) {
case "C":
base = 0;
break;
case "C#":
base = 1;
break;
case "D":
base = 2;
break;
case "D#":
base = 3;
break;
case "E":
base = 4;
break;
case "F":
base = 5;
break;
case "F#":
base = 6;
break;
case "G":
base = 7;
break;
case "G#":
base = 8;
break;
case "A":
base = 9;
break;
case "A#":
base = 10;
break;
case "B":
base = 11;
break;
}
switch (note) {
case "Do":
shift = 0;
break;
case "Re":
shift = 2;
break;
case "Mi":
shift = 4;
break;
case "Fa":
shift = 5;
break;
case "So":
shift = 7;
break;
case "La":
shift = 9;
break;
case "Ti":
shift = 11;
break;
}
if (base + shift > notes.length - 1) {
result = base + shift - notes.length;
}
else {
result = base + shift;
}
return notes[result];
}
}