It is the year 2067. Quantum Space Inc. has grown significantly and is facing a shortage of scientists and engineers. To address this, the company established the Miami Quantum Space College (MQSC) to train future quantum space scientists and engineers. Currently, they use an outdated system of text files to manage student data but are planning to upgrade to a new system. Your task is to ensure that the data in the files remains uncorrupted. Write a program that:

1. Asks the user for an input file name.
2. Validates that the user entered a valid file name (the name of an existing file).
3. If the user enters invalid file names three times, displays an error message and exits the program.
4. Reads from the input file the names of four students and their grades (three grades per student). Store the students' names in a one-dimensional array and their grades in a two-dimensional array. This structure ensures that each student's name is associated with their grades (parallel arrays).
5. After loading the student data into the arrays, display each student's name followed by their grades in the console as shown below:

Example output:
```
Rodolfo 98.9 99.5 100
Julio 78.1 90 89
Pedro 100 100 100
Maria 99 99.8 90
```

Input file structure:
```
Student 1 Name
Student 1 Grade 1
Student 1 Grade 2
Student 1 Grade 3
Student 2 Name
Student 2 Grade 1
Student 2 Grade 2
Student 2 Grade 3
...
```

Make sure to implement the program correctly to maintain data integrity.

Answer :

Final answer:

To validate and read data from text files in a program, prompt the user for a file name and check its validity. Keep track of invalid attempts, read the data into arrays, and display the student names and grades.

Explanation:

To create a program that validates and reads data from text files, you can use the following steps:

  1. Prompt the user to enter a file name.
  2. Check if the file exists using file validation methods.
  3. Keep track of invalid file name attempts and display an error message if the limit is reached.
  4. If the file is valid, read the data into arrays.
  5. Store the student names in a one-dimensional array and their grades in a two-dimensional array.
  6. Display the student names followed by their grades to the console.

By following these steps, you can ensure that the data in the files is not corrupted and can be used for further processing or analysis.

Learn more about Working with text files in a program here:

https://brainly.com/question/34232104

#SPJ11

Other Questions