2. Create a script with array of structures to store Sailor Warrior's Name and their GPA. You need to type the name and GPA, then the script need to create a txt file based on the name and GPA score. Usagi Tsukino 1.98 Rei Hino 3.2 Amy Mizuno 4.0 Makoto Kino 2.9 Minako Aino 2.21 Haruka Tenou 3.5 Michiru Kaiou 3.78 (Do not ask how I remember all the names!)

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

C PROGRAMMING ONLY PLEASE! NO IOSTREAM.H OR CACIO.H HEADERS PLEASE! THANK YOU!

2. Create a script with array of structures to store Sailor Warrior's Name and their GPA. You
need to type the name and GPA, then the script need to create a txt file based on the name
and GPA score.
Usagi Tsukino 1.98
Rei Hino
3.2
Amy Mizuno
4.0
2.9
Makoto Kino
Minako Aino 2.21
Haruka Tenou 3.5
Michiru Kaiou 3.78
(Do not ask how I remember all the names!)
Transcribed Image Text:2. Create a script with array of structures to store Sailor Warrior's Name and their GPA. You need to type the name and GPA, then the script need to create a txt file based on the name and GPA score. Usagi Tsukino 1.98 Rei Hino 3.2 Amy Mizuno 4.0 2.9 Makoto Kino Minako Aino 2.21 Haruka Tenou 3.5 Michiru Kaiou 3.78 (Do not ask how I remember all the names!)
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

I need the script to create a txt file thats made up of all the individual entries as well as the individual txt files for each entry.

The script pasted below prints individual entries but I need it to print 1 additional txt file thats like a sum of all the other created txt files. Thank you!

//script:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_NAME_LENGTH 50
#define MAX_WARRIORS 7
//Usagi Tsukino 1.98
//Rei Hino 3.2
//Amy Mizuno 4.0
//Makoto Kino 2.9
//Minako Aino 2.21
//Haruka Tenou 3.5
//Michiru Kaiou 3.78

struct SailorWarrior {
    char name[MAX_NAME_LENGTH];
    char name2[MAX_NAME_LENGTH];
    float gpa;
};

int main() {
    struct SailorWarrior warriors[MAX_WARRIORS];
    char filename[MAX_NAME_LENGTH + 5]; // +5 for ".txt\0"
    int i;

    for (i = 0; i < MAX_WARRIORS; i++) {
        printf("Enter the name and GPA for Sailor Warrior #%d: ", i+1);
        scanf("%s    %s    %f", warriors[i].name,warriors[i].name2, &warriors[i].gpa);
        sprintf(filename, "%s.txt", warriors[i].name); // create filename
        FILE* fp = fopen(filename, "w"); // create file
        if (fp == NULL) {
            printf("Failed to create file for Sailor Warrior %s\n", warriors[i].name);
            continue; // skip to next iteration of loop
        }
        fprintf(fp, "Name: %s %s\nGPA: %.2f\n", warriors[i].name,warriors[i].name2, warriors[i].gpa);
        fclose(fp); // close file
    }

    return 0;
}

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
User Defined DataType
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
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