On a piano, a keyu has a frequency, say fo. EACH HIGHER KEY (BLACK AND WHITE) HAS A FREQUENCY OF (F0) * r ^n , where n is the distance ( number of keys) from that that key, and r is 2^(1.0/12.0). Given an inital key frequency, output that frequency and the next 4 higher key frequencies. EX: IF THE INPUT IS 440 , THE OUTPUT IS in coral language

Respuesta :

Answer:

// Program is written in Coral Programming Language

// Comments are used for explanatory purpose

// Program starts here

// Variable declaration

float f0

int numkey

//Prompt user for input

Put "Enter Initial Key Frequency: " to output

f0 = Get next input

//Initialize number of keys

numkey = 1

//Print first key frequency

Put "Key Frequencies: " to output

Put f0 to output

put " " to output

for numkey = 1; numkey <= 4; numkey = numkey + 1

  //Calculate next frequency

  f0 = f0 * RaiseToPower(2,(1.0/12.0))

  //Print Frequency

  Put f0 to output

  Put " " to output

//End of Loop

//End of program

Explanation:

Line 1 to Line 4 are comments

Line 5 and 6 are for variable declarations;

On line 5, variable f0 is declared as float

On line 6, variable numkey is declared as integer

Line 7 is a comment

Line 8 prompts user for input

On line 9, the user input us saved in variable f0

Line 11 initialized numkey to 1

Line 13 prints the string "Key Frequencies: " without the quotes

Line 14 prints the value of f0

Line 15 prints a blank

So, if for instance f0 = 440

Line 14 and 15 will print "440 " without the quote

Take note of the space after 440

Line 16 to 22 calculate and print the next 4 frequency using the given formula