I need some code redone, I have a basic setup of the code but I would like to make a few changes to it, in c programming. I know the code works I would just like to see a different way of doing it. The code will function as follows, the code basically allows you to type the persons name and gpa, then creates a txt file with all of the names and gpa. In the photos you can see the current code I have, I would like you to use a similar code to this just not exactly the same, I want to see if there are any other ways to do this code. The txt file should list only 7 people and their gpa.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need some code redone, I have a basic setup of the code but I would like to make a few changes to it, in c programming. I know the code works I would just like to see a different way of doing it. The code will function as follows, the code basically allows you to type the persons name and gpa, then creates a txt file with all of the names and gpa. In the photos you can see the current code I have, I would like you to use a similar code to this just not exactly the same, I want to see if there are any other ways to do this code. The txt file should list only 7 people and their gpa. 

Let me now if you have any questions! Please only use C programming language.

 

 

Enter information of Sailors:
Enter Warrior's First Name: yuji
Enter Warrior's Last Name: itadori
Enter GPA: 1.0
Enter Warrior's First Name: Gojo
Enter Warrior's Last Name: Satoro
Enter GPA: 3.5
|Module 12 hw) My Mac
Finished running Module 12 hw : Module 12 hw
i E E Q A O 6 D e 8 <
|main.e
| sailor.txt
Enter Warrior's First Name: Kugasaki
A Module 12 hw Module 12 hw) sailor.txt > No Selection
v A
A Module 12 hw
Enter Warrior's Last Name: Nobara
1 Name: yujiitadori GPA: 1.00
2 Name: Gojosatoro GPA: 3.50
3 Name: KugasakiNobara GPA: 2.50
4 Name: MegumiFushiguro GPA: 3.20
5 Name: AoiTodo GPA: 1.70
6 Name: TogeInumaki GPA: 4.00
7 Name: YutaOkkotsu GPA: 3.70
Module 12 hw
e main.c
Enter GPA: 2.5
O Number.txt
A sailor.txt
I Distribution.txt
| Products
Enter Warrior's First Name: Megumi
Enter Warrior's Last Name: Fushiguro
Enter GPA: 3.2
Enter Warrior's First Name: Aoi
Enter Warrior's Last Name: Todo
Enter GPA: 1.7
Enter Warrior's First Name: Toge
Enter Warrior's Last Name: Inumaki
Enter information of Sailors:
Enter GPA: 4.0
Enter Warrior's First Name: yuji
Enter Warrior's Last Name: itadori
Enter Warrior's First Name: Yuta
Enter GPA: 1.e
Enter Warrior's First Name: Gojo
Enter Warrior's Last Name: Okkotsu
Enter Warrior's Last Name: Satoro
Enter GPA: 3.5
Enter GPA: 3.7
Displaying information of Sailors:
Enter Warrior's First Name: Kugasaki
Enter Warrior's Last Name: Nobara
Transcribed Image Text:Enter information of Sailors: Enter Warrior's First Name: yuji Enter Warrior's Last Name: itadori Enter GPA: 1.0 Enter Warrior's First Name: Gojo Enter Warrior's Last Name: Satoro Enter GPA: 3.5 |Module 12 hw) My Mac Finished running Module 12 hw : Module 12 hw i E E Q A O 6 D e 8 < |main.e | sailor.txt Enter Warrior's First Name: Kugasaki A Module 12 hw Module 12 hw) sailor.txt > No Selection v A A Module 12 hw Enter Warrior's Last Name: Nobara 1 Name: yujiitadori GPA: 1.00 2 Name: Gojosatoro GPA: 3.50 3 Name: KugasakiNobara GPA: 2.50 4 Name: MegumiFushiguro GPA: 3.20 5 Name: AoiTodo GPA: 1.70 6 Name: TogeInumaki GPA: 4.00 7 Name: YutaOkkotsu GPA: 3.70 Module 12 hw e main.c Enter GPA: 2.5 O Number.txt A sailor.txt I Distribution.txt | Products Enter Warrior's First Name: Megumi Enter Warrior's Last Name: Fushiguro Enter GPA: 3.2 Enter Warrior's First Name: Aoi Enter Warrior's Last Name: Todo Enter GPA: 1.7 Enter Warrior's First Name: Toge Enter Warrior's Last Name: Inumaki Enter information of Sailors: Enter GPA: 4.0 Enter Warrior's First Name: yuji Enter Warrior's Last Name: itadori Enter Warrior's First Name: Yuta Enter GPA: 1.e Enter Warrior's First Name: Gojo Enter Warrior's Last Name: Okkotsu Enter Warrior's Last Name: Satoro Enter GPA: 3.5 Enter GPA: 3.7 Displaying information of Sailors: Enter Warrior's First Name: Kugasaki Enter Warrior's Last Name: Nobara
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct sailor
{
char warriorfName[50];
char warriorlName[50];
float gpa;
};
int main()
{
int i;
struct sailor sail[10];
FILE *fp;
fopen("sailor.txt", "w+");
fp
printf("Enter information of Sailors:\n");
for(i=0;i<7;i++)
{
printf("\nEnter Warrior's First Name: ");
scanf("%s",sail[i].warriorfName);
printf("\nEnter Warrior's Last Name: ");
scanf("%s",sail[i].warriorlName);
printf("\nEnter GPA: ");
scanf("%f",&sail[i].gpa);
}
printf("Displaying information of Sailors:\n\n");
for (i=0;i<7;i++)
{
fputs("Name: ",fp);
fputs(sail[i].warriorfName, fp);
fputs(sail[i].warrior1Name, fp);
fputs(" GPA: ",fp);
fprintf(fp, "%0.2f", sail[i].gpa);
fputs("\n",fp);
}
fclose(fp);
printf("\nData written to sailor.txt");
getchar();
Transcribed Image Text:#include <stdio.h> #include <string.h> #include <stdlib.h> struct sailor { char warriorfName[50]; char warriorlName[50]; float gpa; }; int main() { int i; struct sailor sail[10]; FILE *fp; fopen("sailor.txt", "w+"); fp printf("Enter information of Sailors:\n"); for(i=0;i<7;i++) { printf("\nEnter Warrior's First Name: "); scanf("%s",sail[i].warriorfName); printf("\nEnter Warrior's Last Name: "); scanf("%s",sail[i].warriorlName); printf("\nEnter GPA: "); scanf("%f",&sail[i].gpa); } printf("Displaying information of Sailors:\n\n"); for (i=0;i<7;i++) { fputs("Name: ",fp); fputs(sail[i].warriorfName, fp); fputs(sail[i].warrior1Name, fp); fputs(" GPA: ",fp); fprintf(fp, "%0.2f", sail[i].gpa); fputs("\n",fp); } fclose(fp); printf("\nData written to sailor.txt"); getchar();
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY