Question: Write a program called LoopyMelody in your mmw package that will 1 . accept, from the standard input stream, data corresponding to the number of

Write a program called LoopyMelody in your mmw package that will 1. accept, from the standard input stream, data corresponding to the number of notes per line of melody and number of pitches to shift up from middle A.2. allow for a random shift relative to middle A.3. print, to the standard output stream, the resulting melody 4. while using a while loop. In addition to the above description, the melody that you are to create has a rigid structure that is more thoroughly described in the leading comment of the code provided. Your programs output should be consistent with the following demoes, which you should study to understand the structure of the melody. Pay special attention to the alignment of the user-entered input and the prompts. 1 run : 2 Enter the number of notes per row melody : 53 Enter the shift (0-8) above middle A , or -1 for a random shift : 24 Here s your melody !5(C ,1/2)(C ,1/2)(C ,1/2)(C ,1/2)\(A ,1/2)6/(C ,1/2)(C ,1/2)(C ,1/2)\(A ,1/2)/(D ,1)7\(C ,1/2)(C ,1/2)\(A ,1/2)/(D ,1)/(E ,1)8\(C ,1/2)\(A ,1/2)/(D ,1)/(E ,1)/(F ,1)9\(E ,1/2)\(D ,1)/(E ,1)/(F ,1)/(G ,1)10\(C ,1/2)/(E ,1/2)\(D ,1)/(E ,1)/(F ,1)11\(C ,1/2)(C ,1/2)/(E ,1/2)\(D ,1)/(E ,1)12\(C ,1/2)(C ,1/2)(C ,1/2)/(E ,1/2)\(D ,1)13\(C ,1/2)(C ,1/2)(C ,1/2)(C ,1/2)/(E ,1/2)(E ,2)1 run : 2 Enter the number of notes per row melody : 43 Enter the shift (0-8) above middle A , or -1 for a random shift : 54 Here s your melody !5(F ,1/2)(F ,1/2)(F ,1/2)\(D ,1/2)6/(F ,1/2)(F ,1/2)\(D ,1/2)/(G ,1)7\(F ,1/2)\(D ,1/2)/(G ,1)/(A ,1)8(A ,1/2)\(G ,1)/(A ,1)/(B ,1)9\(F ,1/2)/(A ,1/2)\(G ,1)/(A ,1)10\(F ,1/2)(F ,1/2)/(A ,1/2)\(G ,1)11\(F ,1/2)(F ,1/2)(F ,1/2)/(A ,1/2)(A ,2)1 run : 2 Enter the number of notes per row melody : 63 Enter the shift (0-8) above middle A , or -1 for a random shift : -14 Here s your melody !5(G ,1/2)(G ,1/2)(G ,1/2)(G ,1/2)(G ,1/2)\(E ,1/2)6/(G ,1/2)(G ,1/2)(G ,1/2)(G ,1/2)\(E ,1/2)/(A ,1)7\(G ,1/2)(G ,1/2)(G ,1/2)\(E ,1/2)/(A ,1)/(B ,1)8\(G ,1/2)(G ,1/2)\(E ,1/2)/(A ,1)/(B ,1)/(C ,1)9\(G ,1/2)\(E ,1/2)/(A ,1)/(B ,1)/(C ,1)/(D ,1)10\(B ,1/2)\(A ,1)/(B ,1)/(C ,1)/(D ,1)/(E ,1)11\(G ,1/2)/(B ,1/2)\(A ,1)/(B ,1)/(C ,1)/(D ,1)12\(G ,1/2)(G ,1/2)/(B ,1/2)\(A ,1)/(B ,1)/(C ,1)13\(G ,1/2)(G ,1/2)(G ,1/2)/(B ,1/2)\(A ,1)/(B ,1)14\(G ,1/2)(G ,1/2)(G ,1/2)(G ,1/2)/(B ,1/2)\(A ,1)15\(G ,1/2)(G ,1/2)(G ,1/2)(G ,1/2)(G ,1/2)/(B ,1/2)(B ,2) Moreover, your program should be consistent with the following Java program text and the iteration should be done with while loops only. What I did was to write the program, and then delete the bodies of some of the methods. Your job is to add the instructions back. Or at least, instructions that will do the job and utilize while loops. Other than adding instructions in the indicated methods, all of the executable code should remain exactly as in the accompanying program text. which means that you are free to add comments to yourself as needed. You should 2024 Daniel Schlegel & Elizabeth Wilcox Reproduction prohibited without author consent 2 CS1(CSC 212) Programming Challenge #5 Fall 2024 be able to use your program to generate the melodies that appear in my demo, and many others, as well. 1/*2* Program to create an iterative melody . The lines start out playing the same 3*" baseline " pitch for 1/2 duration , with a two - pitch " shift note "( lowered 4* at first ). Over the lines , the constant " baseline " pitch is played 5* fewer times , and more and more rising pitches are played .6*7* Then , only the " shift note ", now two pitches higher , is played along with 8* the rising pitch melody .9*10* Lastly , the constant " baseline " pitch starts to make its return with the 11* rising pitch melody subsides . In this part , the " shift note " is also 12* two pitches higher than the " baseline " pitch . The melody ends 13* with the " shift note " played for a duration of 2 beats .14*15* The number of notes in each line is read from the standard input stream , and 16* the initial pitch is either read from the standard input stream as a pitch 17* shift or randomly selected from 0,1,2,3,4,5,6,7, or 8.18*/19 package mmw ; 2021 import note . SNote ; 22 import java . util . Scanner ; 2324 public class LoopyMelody {2526 public static void main ( String [] args )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!