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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education