If you have any doubts, please give me comment...
Lab5A.c
#include<stdio.h>
struct student{
char firstname[40];
char lastname[40];
int id;
float GPA;
int year;
};
typedef struct student Student;
void InputStdRecord(Student *StdList);
void PrintStdList(const Student *StdList);
void SaveStdList(const Student *StdList, const char *FileName);
int main(){
Student StdList[5];
InputStdRecord(StdList);
PrintStdList(StdList);
SaveStdList(StdList, "stdInfo.txt");
return 0;
}
void InputStdRecord(Student *StdList){
int i=0;
for(i=0; i<4; i++){
printf("\nEnter Student %d details: \n", i+1);
printf("ID: ");
scanf("%d", &StdList[i].id);
printf("Firstname: ");
scanf("%s", StdList[i].firstname);
printf("Lastname: ");
scanf("%s", StdList[i].lastname);
printf("GPA: ");
scanf("%f", &StdList[i].GPA);
printf("Year: ");
scanf("%d", &StdList[i].year);
}
}
void PrintStdList(const Student *StdList){
printf("\nID FIRSTNAME LASTNAME GPA YEAR\n");
int i;
for(i=0; i<4; i++){
printf("%d %s %s %.1f %d\n", StdList[i].id, StdList[i].firstname, StdList[i].lastname, StdList[i].GPA, StdList[i].year);
}
}
void SaveStdList(const Student *StdList, const char *FileName){
FILE *fp;
fp = fopen(FileName, "w");
fprintf(fp, "ID FIRSTNAME LASTNAME GPA YEAR\n");
int i;
for(i=0; i<4; i++){
fprintf(fp, "%d %s %s %.1f %d\n", StdList[i].id, StdList[i].firstname, StdList[i].lastname, StdList[i].GPA, StdList[i].year);
}
fclose(fp);
}
Lab5B.c
#include<stdio.h>
struct student{
char firstname[40];
char lastname[40];
int id;
float GPA;
int year;
};
typedef struct student Student;
void ReadStdRecords(Student *StdList, const char *FileName);
void PrintStdList(const Student *StdList);
void wordCap(char *word);
void SaveStdList(const Student *StdList, const char *FileName);
int main(){
Student StdList[5];
ReadStdRecords(StdList, "stdInfo.txt");
PrintStdList(StdList);
SaveStdList(StdList, "stdInfo.txt");
return 0;
}
void ReadStdRecords(Student *StdList, const char *FileName){
FILE *fp;
fp = fopen(FileName, "r");
int i=0;
//for skipping first line
fscanf(fp, "%[^\n]s", StdList[0].firstname);
for(i=0; i<5; i++){
fscanf(fp, "%d %s %s %f %d", &StdList[i].id, StdList[i].firstname, StdList[i].lastname, &StdList[i].GPA, &StdList[i].year);
wordCap(StdList[i].firstname);
wordCap(StdList[i].lastname);
}
fclose(fp);
}
void PrintStdList(const Student *StdList){
printf("\nID FIRSTNAME LASTNAME GPA YEAR\n");
int i;
for(i=0; i<4; i++){
printf("%d %s %s %.1f %d\n", StdList[i].id, StdList[i].firstname, StdList[i].lastname, StdList[i].GPA, StdList[i].year);
}
}
void wordCap(char *word){
int i=0;
while(word[i]!='\0'){
if(word[i]>='a' && word[i]<='z')
word[i] = word[i]-32;
i++;
}
}
void SaveStdList(const Student *StdList, const char *FileName){
FILE *fp;
fp = fopen(FileName, "w");
fprintf(fp, "ID FIRSTNAME LASTNAME GPA YEAR\n");
int i;
for(i=0; i<4; i++){
fprintf(fp, "%d %s %s %.1f %d\n", StdList[i].id, StdList[i].firstname, StdList[i].lastname, StdList[i].GPA, StdList[i].year);
}
fclose(fp);
}
In c programming . Part A: Writing into a Sequential File Write a C program called...
Rework this project to include a class. As explained in class, your project should have its functionalities moved to a class, and then create each course as an object to a class that inherits all the different functionalities of the class. You createclass function should be used as a constructor that takes in the name of the file containing the student list. (This way different objects are created with different class list files.) Here is the code I need you...
Using the program segment and sample txt file below, write a program that contains a linked list of students. The program should allow the user to: 1. initialize list of students 2. add additional student to front of list 3. add additional student to rear of list 4. delete student 5. sort students alphabetically 6. sort students by idNum 7. show number of students in list 8. print students 9. quit program XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The program should be divided into the...
Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...
Write a C++ program that includes the following: Define the class Student in the header file Student.h. #ifndef STUDENT_H #define STUDENT_H #include <string> #include <iostream> using namespace std; class Student { public: // Default constructor Student() { } // Creates a student with the specified id and name. Student(int id, const string& name) { } // Returns the student name. string get_name() const { } // Returns the student id. int get_id () const { } // Sets the student...
A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double GPA(=(4.0*NumberOfAs+3.0*NumberOfBs+2.0*NumberOfCs+1.0*NumberOfDs)/( As+Bs+Cs+Ds+Fs)); Public data member, void setFirstName(string name); string getFirstName() const; void printFirstName() const; void getLastName(string name); string getLastName() const; void printLastName() const; void computeGPA(int NumberOfAs,int NumberOfBs,int NumberOfCs,int NumberOfDs,int NumberOfFs); double getGPA() const; double printGPA() const; A destructor and an explicit default constructor initializing GPA=0.0 and checking if GPA>=0.0 by try{}catch{}. Add member function, bool operator<(const Student); The comparison in this function based on...
Write in C++ 1. Use the following Person class (Person.cpp, Person.h). You will be writing Person objects to a random access file. --------------------- Person.cpp--------------------------------- // Class Person stores customer's credit information. #include <string> #include "Person.h" using namespace std; // default Person constructor Person::Person( int idValue, string lastNameValue, string firstNameValue, int AgeValue ) { setID( idValue ); setLastName( lastNameValue ); setFirstName( firstNameValue ); setAge( AgeValue ); } // end Person constructor // get id value int Person::getID() const { return id;...
FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Must be written and C, and compile with MinGW. Thank
you!
am Specification For this assignment, you will write a multi-file C program to define, implement and use a dynamic linked lists. Please refer to Lab 07 for the definition of a basic linked list. In this assignment you will need to use the basic ideas of a node and of a linked list of nodes to implement a suit of functions which can be used to create and maintain...
Program in C Student Data using Structs In this assignment you will create a program (using multiple .c files) to solve the following problem: You have been hired by the university to create a program that will read in input from a .txt file. This input will contain a student name, student id #, their age and their current gpa. You should use the following struct for your student data: struct Student{ char name[50]; int id; float...