In: Mechanical Engineering
The purpose of this problem is to use graphic user interface (GUI) to interactively store grades in a text file, rather than adding them manually to a script. Follow these steps to complete the program:
Step 1. Use a question dialog box and ask the user “Do you want to run this Program?” with two options for “yes” and “no”. If the user’s answer is “yes”, go to the next step, otherwise, go to Step 6.
Step 2. Create a file using fopen command to store the data.
Step 3. Use a while loop and create an input dialog box similar to that of Figure 1 inside the loop.
Step 4. Every time that the users enters the values, check whether the grade is -1 or not. If the grade is not -1, store the name, student ID, and grade in one line in the file using fprintf command. If the Student ID was shorter or longer than 7 digits, an error dialog box should appear and give an appropriate error message and display a fresh input dialog box. If the entry was correct, make sure to separate the data at each line by using horizontal tabs (this can be done by typing \t in the fprintf argument). Remember that the output of an input dialog box is a cellular array and you have to convert it into a string (by using curled brackets to access a specific element of the input dialog result) before storing it in a file.
Step 5. Close the file.
Step 6. Output a message using a message dialog box indicating that the problem is terminated. If you would like to use strcmp function, you may.
Step 7. Write the same code in a way that it stores the data in an Excel spreadsheet with proper formatting