C++
I need to use the function getData to put in all my data using arrays. I need the program to use a function called displayData and will output the text file called students.txt and it will be grabbing the name, gender, age, id, GPA.
Example of text file :
Joe Clarkson
M
13
863546
4.0
Klent Patterson
M
51
346347
2.4
It will just get the text file and say:
The person's name is : Joe Clarkson
The person's gender is : M
The person's age is : 13
The person's id is: 863546
The person's GPA is : 4.0
Hey here is answer to your question.
In case of any doubt comment below. Please UPVOTE if you Liked the answer.
#include <bits/stdc++.h>
using namespace std;
void getData(){
ifstream file("students.txt");
string str;
string name,gender;
int counter = 0;
vector<string> colour;
while (getline(file, str)) {
colour.push_back(str);
}
int temp;
for (int i = 0; i < colour.size()/5; i++) {
temp = i*5;
cout<<"The person's name is : "
<<colour[temp]<<endl;
cout<<"The person's gender is
: " <<colour[temp+1] <<endl;
cout<<"The person's age is :
" <<colour[temp+2]<<endl;
cout<<"The person's id is :
" <<colour[temp+3]<<endl;
cout<<"The person's GPA is :
" <<colour[temp+4]<<endl;
}
}
int main ()
{
getData();
}

C++ I need to use the function getData to put in all my data using arrays....
I need help solving this C++ problem please. A data file will be provided that contains the first names and student IDs for a class. Write a program that stores this information using parallel arrays in C++. Assume that the data file will be named "students.txt" and will contain information with no more than 100 students. You can also assume that none of the first names will contain any spaces. The program will need to contain four functions: Read data...
Hello I need help fixing my C++ code. I need to display in the
console the information saved in the file as well have the content
saved in the file output in a fixed position like the screenshot.
Thanks.
CODE
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
//main function
int main()
{
//variable to store student id
int id;
//variables to store old gpa(ogpa), old course
credits(occ), new course credits(ncc), current gpa(cur_gpa),
cumulative gpa(cum_gpa)
float ogpa,...
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...
Hello I need a small fix in my program. I need to display the youngest student and the average age of all of the students. It is not working Thanks. #include <iostream> #include <iomanip> #include <fstream> #include <vector> #include <algorithm> using namespace std; struct Student { string firstName; char middleName; string lastName; char collegeCode; int locCode; int seqCode; int age; }; struct sort_by_age { inline bool operator() (const Student& s1, const Student& s2) { return (s1.age < s2.age); // sort...
Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that has been collected. See file universities.txt .Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment, one for average freshman retention, and one for the percent of students who graduate with in six years. Note that the percentage of student accepted is not stored.An output file is opened in main() and...
Hello, I need to implement these small things in my C++ code. Thanks. 1- 10 characters student first name, 10 characters middle name, 20 characters last name, 9 characters student ID, 3 characters age, in years (3 digits) 2- Open the input file. Check for successful open. If the open failed, display an error message and return with value 1. 3- Use a pointer array to manage all the created student variables.Assume that there will not be more than 99...
I need only one C++ function . It's C++ don't
write any other language.
Hello I need unzip function here is my zip function
below. So I need the opposite function unzip.
Instructions:
The next tools you will build come in a pair, because
one (zip) is a file compression tool, and
the other (unzip) is a file decompression
tool.
The type of compression used here is a simple form of
compression called run-length encoding (RLE). RLE is quite simple:
when...
I need help making my array into a function that can called by
the main function using my program. This is C programming
int prime (int x) {
int i;
i = 2;
while (i < x) {
if (x % i == 0) return 0;
i++;
}
return 1;
}
int main (void){
int n;
scanf ("%d", &n);
if (n < 1) {
printf ("Error: at least one data value must be
provided.\n");
return 1;
}
int a[n];
int...
I need only one C++ function . It's C++ don't write any other language. Hello I need unzip function here is my zip function below. So I need the opposite function unzip. Instructions: The next tools you will build come in a pair, because one (zip) is a file compression tool, and the other (unzip) is a file decompression tool. The type of compression used here is a simple form of compression called run-length encoding (RLE). RLE is quite simple: when...
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...