1. practise file I/O and exception handling; 2. practise String processing. Aim: Task: Create a Java application that transcripts a simple song score sheet. The program asks user for filename of a text file that contains a simple song score sheet in this format: Sample song score sheet 1, song1.txt: #simple song with assumed time signature = 4 d1mls2o2s1mld2o2 dlrimlfls301s1flm1rld4

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Java code

#Time Signature
Do- Re Me Fa So La Ti
#Time Signature =
= 2
4
Do---
| Re---
| Off- Me-
Then, the program terminates.
To simplify this task, we assume:
Input song text files always contain valid data.
The time signature designation and the note durations are always valid.
Section bars shall NOT cut a multiple beat notes, e.g., Do--
A section shall not continue between two lines.
We accept optionally an extra space at the end of the output lines.
Re- will NOT happen.
Procedure:
1.
Work under a NetBeans Java Application project MusicApp. Name the package as musicapp.
2. Complete the program according to the above descriptions as well as the samples given.
Note that file operations may fail. We give the user THREE chances to input a proper input
filename. If all fails, the program terminates with System. exit (1).
Song filename: a.exe
Something wrong!
Song filename: C:/xyz
Something wrong!
Song filename:
Something wrong!
a
3.
Screen output of a complete sample run with text in blue indicates user keyboard input:
Song filename: a
Something wrong!
Song filename: a.exe
Something wrong!
Song filename: song2.txt
Reading song file song2.txt
#song with different time signatures
#Time Signature = 3
Do Re Me
Do Re Me
#Time Signature = 2
Do- Re Me Fa So | La Ti
#Time Signature = 4
Off-- Me Re Do ||
Fa So Off | So Fa Me | Re Do- |
Do---
| Re---
| Off- Me- |
The program also outputs those text in yellow highlight to another output text file named
melody_song2.txt,i.e., prefixed melody_<inputFilename>.
Transcribed Image Text:#Time Signature Do- Re Me Fa So La Ti #Time Signature = = 2 4 Do--- | Re--- | Off- Me- Then, the program terminates. To simplify this task, we assume: Input song text files always contain valid data. The time signature designation and the note durations are always valid. Section bars shall NOT cut a multiple beat notes, e.g., Do-- A section shall not continue between two lines. We accept optionally an extra space at the end of the output lines. Re- will NOT happen. Procedure: 1. Work under a NetBeans Java Application project MusicApp. Name the package as musicapp. 2. Complete the program according to the above descriptions as well as the samples given. Note that file operations may fail. We give the user THREE chances to input a proper input filename. If all fails, the program terminates with System. exit (1). Song filename: a.exe Something wrong! Song filename: C:/xyz Something wrong! Song filename: Something wrong! a 3. Screen output of a complete sample run with text in blue indicates user keyboard input: Song filename: a Something wrong! Song filename: a.exe Something wrong! Song filename: song2.txt Reading song file song2.txt #song with different time signatures #Time Signature = 3 Do Re Me Do Re Me #Time Signature = 2 Do- Re Me Fa So | La Ti #Time Signature = 4 Off-- Me Re Do || Fa So Off | So Fa Me | Re Do- | Do--- | Re--- | Off- Me- | The program also outputs those text in yellow highlight to another output text file named melody_song2.txt,i.e., prefixed melody_<inputFilename>.
Music App
1. practise file I/O and exception handling;
2. practise String processing.
Aim:
Task: Create a Java application that transcripts a simple song score sheet.
The program asks user for filename of a text file that contains a simple song score sheet in this format:
Sample song score sheet 1, song1.txt:
#simple song with assumed time signature = 4
d1mls202s 1mld2o2
d1rimlfls 301s1f1m1rld4
Lines beginning with a hash #' is a comment line. A song contains one or more lines of musical
notes, d, r, m, f, s, l, tand also o meaning "Off" or rest. Each single character note is
followed by a single digit integer in [1 – 4], denoting the duration of the note in number of beats.
After transcription, the program outputs the melody on the screen as well as to another text file:
Melody output 1, on screen AND in melody_song1.txt:
#simple song with assumed time signature
Do Me So- Off- So Me
Do Re Me Fa| So-- Off
= 4
Do- Off- |
So Fa Me Re Do---
|
The default time signature is 4 beats per section. Sections are delimited by bars '. Notes are
converted into full-names with 2 characters, Do, Re, Me, Fa, So, La, Ti, and Off. Notes lasting for
one beat are displayed directly. A note lasting two or more beats are elongated with a display of
dashes -', e.g., So-- for s3. Notes and bars are delimited by a space.
Time signature can be changed with a newline starting with an asterisk *', followed by a single digit
integer n in [1– 6]. Transcript and output such a line as "#Time Signature = n", e.g.,
Sample song score sheet 2, song2.txt:
#song with different time signatures
*3
d1rimlo3m1r1d1
d1rımlflslols1flm1r1d2
*2
d2r1mlfls111t1
*4
d4r4o2m2
Melody output 2, on screen AND in melody_song2.txt:
#song with different time signatures
#Time Signature = 3
Do Re Me Off--| Me Re Do
Do Re Me Fa So Off So Fa Me
Re Do-
Transcribed Image Text:Music App 1. practise file I/O and exception handling; 2. practise String processing. Aim: Task: Create a Java application that transcripts a simple song score sheet. The program asks user for filename of a text file that contains a simple song score sheet in this format: Sample song score sheet 1, song1.txt: #simple song with assumed time signature = 4 d1mls202s 1mld2o2 d1rimlfls 301s1f1m1rld4 Lines beginning with a hash #' is a comment line. A song contains one or more lines of musical notes, d, r, m, f, s, l, tand also o meaning "Off" or rest. Each single character note is followed by a single digit integer in [1 – 4], denoting the duration of the note in number of beats. After transcription, the program outputs the melody on the screen as well as to another text file: Melody output 1, on screen AND in melody_song1.txt: #simple song with assumed time signature Do Me So- Off- So Me Do Re Me Fa| So-- Off = 4 Do- Off- | So Fa Me Re Do--- | The default time signature is 4 beats per section. Sections are delimited by bars '. Notes are converted into full-names with 2 characters, Do, Re, Me, Fa, So, La, Ti, and Off. Notes lasting for one beat are displayed directly. A note lasting two or more beats are elongated with a display of dashes -', e.g., So-- for s3. Notes and bars are delimited by a space. Time signature can be changed with a newline starting with an asterisk *', followed by a single digit integer n in [1– 6]. Transcript and output such a line as "#Time Signature = n", e.g., Sample song score sheet 2, song2.txt: #song with different time signatures *3 d1rimlo3m1r1d1 d1rımlflslols1flm1r1d2 *2 d2r1mlfls111t1 *4 d4r4o2m2 Melody output 2, on screen AND in melody_song2.txt: #song with different time signatures #Time Signature = 3 Do Re Me Off--| Me Re Do Do Re Me Fa So Off So Fa Me Re Do-
Expert Solution
steps

Step by step

Solved in 6 steps with 5 images

Blurred answer
Knowledge Booster
Exception Handling Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT