Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java. Write a call to the method majorKeyso that the println statement will not

ID: 3842875 • Letter: J

Question

Java.

Write a call to the method majorKeyso that the println statement will not generate a syntax error.

import java.util.Scanner;
public class FinalCall {

public static void main (String args[]) {

Scanner keyboard = new Scanner(System.in);
int majIndex = 7;
char majorValue, sharpe[] = {'F', 'C', 'G', 'D', 'A', 'E', 'B'};
String opusName = keyboard.nextLine();
// the call to majorKey goes here
System.out.println("Major key: " + majorValue);

}
public static char majorKey(char key[], String name, int majIndex ) {
char thiskey = key[majIndex%7];
for (int i = 1; i < key.length; i++)
if (key[i] != 'C'))

return key[i];

if (name.equals("major"));

return thiskey;

else

return 'C';

}

}

Explanation / Answer

FinalCall.java


import java.util.Scanner;
public class FinalCall {
public static void main (String args[]) {
Scanner keyboard = new Scanner(System.in);
int majIndex = 7;
char majorValue, sharpe[] = {'F', 'C', 'G', 'D', 'A', 'E', 'B'};
String opusName = keyboard.nextLine();
// the call to majorKey goes here
System.out.println("Major key: " + majorKey(sharpe,opusName,majIndex));
}
public static char majorKey(char key[], String name, int majIndex ) {
char thiskey = key[majIndex%7];
for (int i = 1; i < key.length; i++)
if (key[i] != 'C')
return key[i];
if (name.equals("major"))
return thiskey;
else
return 'C';
}
}

Output:

good morning
Major key: G

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote