Write in c++ please
Read and write 5 students information such as, Student ID, first name, last name, GPA and Student Major from the txt file using Structure.
Answer:
code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct Student{ //defining the structure to store the data given in
the data file
int id;
char first[10];
char last[10];
float GPA;
char major[5];
};
int main () {
string in;
Student stud[5];
ifstream inFile("data.txt"); //reding the file
if (!inFile){
cerr << "File can't be opened! " << endl; //display
error if the file can't be opened
system("PAUSE");
exit(1);
}
for(int i=0; i<5; i++){
inFile>>stud[i].id>>stud[i].first>>stud[i].last>>stud[i].GPA>>stud[i].major;
//inserting the values of the file in the student record
}
for(int i=0; i<5; i++){
cout<<stud[i].id<<endl; //Displaying the
output to the screen
cout<<stud[i].first<<endl;
cout<<stud[i].last<<endl;
cout<<stud[i].GPA<<endl;
cout<<stud[i].major<<endl;
}
return 0;
}
data.txt:
Output:
Please give it a thumbs up if this helped you, also provide your valuable feedback.
Write in c++ please Read and write 5 students information such as, Student ID, first name,...
A. Consider “inclass2.h” header file. Define a structure which can hold the following student information: id, first name, last name, and gpa. Use appropriate header file guards. ( Max size of first and last name is 20, id is 7 and gpa is double). B. Consider an array of student struct with the MAX_SIZE 10 and a first name. These will be provided as an input to your function. Write a function/method that using the given inputs prints out the...
In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...
IN C PLEASE Question 16 A. Consider “inclass2.h” header file. Define a structure which can hold the following student information: id, first name, last name, and gpa. Use appropriate header file guards. ( Max size of first and last name is 20, id is 7 and gpa is double). B. Consider an array of student struct with the MAX_SIZE 10 and a first name. These will be provided as an input to your function. Write a function/method that using the...
Write a java program to create a student file which includes first name, last name, and GPA. Write another Java program to open the students file. Display the students list and calculate the average GPA of the class.
2. Write a program named lab3 2.app that contains a class named Student to store student information Information that will be relevant to store is first name, last name, id number, GPA, and major (1) Define a member function named set0, which allows you to set all member variables. This function has an empty parameter list, and its return type is void. So, within the function you'll prompt for information. Note: For entering major, if you need a space, use...
Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student number 54812 to 80. /* File: course.cpp A student's mark in a certain course is stored as a structure (struct student as defined below) consisting of first and last name, student id and mark in the course. The functions read() and write() are defined for the structure student. Information about a course is stored as a...
A few students forgot to write their identification information such as name or student id on their final exams. What are some of the data preprocessing strategies that you will use to deal with these missing values?
Write a java code : Student ID at University is composed of year of admission and students number. we aim to implement a structure that improves operations of inserting and searching for a student. To enhance these operations, we will build a tree of linked lists (TreeOfLists) to combine advantages of both structures. Each node in this tree contains a linked list of all students who were admitted in that year. Each node in the linked list represents a student(id,...
C Program: Write a program that will read names, ids, dept names, and cgpа of some students from a file and will show the results. Consider that the name of the file is 'input.csv'. It is just a text file where each line holds information of one student. Example format of two lines in the file is as follows: David Smith, 21, Computer Science, 3.98 Jone Smith, 11, Finance, 3.45 Read all information from the file, and print them on...
Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...