Question
Have to create files named main.cpp GPA.h GPAlist.cpp GPAlist.h File.cpp File.h UI.h UI.cpp Among these files the main.cpp and the GPA.h files are given and
Have to create files named
main.cpp
GPA.h
GPAlist.cpp
GPAlist.h
File.cpp
File.h
UI.h
UI.cpp
Among these files the main.cpp and the GPA.h files are given and there is a data file named student.csv which contains data for the output
The codes for the main.cpp file is as below.
main.cpp
#include
#include "GPAlist.h"
int main() {
if(gpaQuery("std.csv")) {
std::cout << "This should have failed!" << std::endl;
} else {
std::cout << "failed!, this is the correct exectution" << std::endl;
}
if(!gpaQuery("students.csv")) {
std::cout << "This should have worked, fix the problem!" << std::endl;
}
std::cout << "Goodbye!" << std::endl;
return 0;
}
The code for the GPA.h file is
#ifndef SDDS_GPA_H
#define SDDS_GPA_H
struct GPA {
char name[116];
double gpa;
int stno;
};
#endif // !SDDS_GPA_H
The data file named student.csv is as follows
Abraham Simpson,324543,3.9
Agnes Skinner,470546,4.0
Akira Kurosawa,411928,2.1
Alice Glick,459608,3.3
Allison Taylor,747954,2.3
Apu Nahasapeemapetilon,290816,4.0
Artie Ziff,245446,3.6
Baby Gerald,155387,3.9
Barney Gumble,262592,1.7
Bart Simpson,753102,1.8
Bernice Hibbert,242653,3.9
Brandine Spuckler,584416,1.7
Bumblebee Man,603577,3.1
Carl Carlson,241968,3.0
Chazz Busby,362030,3.7
Cletus Spuckler,653783,2.9
Comic Book Guy,234272,3.7
Dewey Largo,910346,2.5
Disco Stu,736389,4.0
Dolph Starbeam,829982,3.9
Drederick Tatum,937537,2.3
Edna Krabappel,877842,1.6
Elizabeth Hoover,389470,3.5
Gil Gunderson,383513,1.7
Gloria Jailbird,601956,3.2
Groundskeeper Willie,774965,2.8
Hans Moleman,217944,2.3
Helen Lovejoy,686009,1.8
Herman Hermann,164996,2.2
Homer Simpson,413084,2.1
Jacqueline Bouvier,522856,2.3
Janey Powell,919159,2.2
Jasper Beardly,417008,3.6
Jessica Lovejoy,667331,1.9
Jimbo Jones,718588,3.6
Johnny Tightlips,840329,3.3
Judge Roy Snyder,533451,1.8
Kearney Zzyzwicz,758048,2.8
Kent Brockman,568727,1.7
Kirk Van Houten,695606,1.6
Krusty The Clown,901832,4.0
Kumiko Albertson,339422,3.5
Lenny Leonard,562762,2.6
Lindsey Naegle,570423,4.0
Ling Bouvier,249669,4.0
Lionel Hutz,212516,2.8
Lisa Simpson,693664,2.3
Luann Van Houten,737447,2.7
Luigi Risotto,757705,2.5
Lunchlady Doris,895470,3.0
Maggie Simpson,712478,3.1
Manjula Nahasapeemapetilon,236261,2.3
Marge Simpson,695580,3.1
Martin Prince,575687,2.3
Maude Flanders,272754,2.3
Mayor Joe Quimby,425163,3.0
Milhouse Van Houten,619711,2.9
Miss Springfield,855862,3.5
Moe Szyslak,219634,3.2
Mona Simpson,419417,3.4
Ned Flanders,746703,2.5
Nelson Muntz,584760,2.4
Old Jewish Man,259301,2.3
Patty Bouvier,544545,3.1
Rabbi Hyman Krustofsky,374366,3.5
Rainier Wolfcastle,674248,2.7
Ralph Wiggum,414067,3.5
Rod Flanders,823458,2.5
Roger Meyers Jr.,313590,2.1
Ruth Powers,231018,3.7
Sarah Wiggum,920562,2.3
Sea Captain,544294,3.7
Selma Bouvier,217994,3.8
Seymour Skinner,434336,1.7
Shauna Chalmers,828516,2.1
Sideshow Mel,799960,2.9
Snake Jailbird,950955,1.8
Squeaky-Voiced Teen,194002,1.8
Surly Duff,146127,3.4
The Rich Texan,300288,2.8
Todd Flanders,257297,2.3
Troy McClure,394769,1.9
Uter Zorker,712465,2.2
Waylon Smithers,387433,3.0
Wendell Borton,677806,1.7
Wise Guy,134681,1.8
A comma-separated file of student records and their GPA (maximum of 100 records) with the following format:
Student Name, Student number, GPA
Sample:
Abraham Simpson,324543,3.9
Agnes Skinner,470546,4.0
Akira Kurosawa,411928,2.1
Alice Glick,459608,3.3
A header file has a structure for the GPA record of a student under the name "GPA.h".
Have to write a command line program that receives an operation and a GPA value and performs the following queries on the records of the data file.
command line format:
? [operation][GPA Value]
Examples:
? <3.6 [ENTER] list all the GPA records less than 3.6
? >3.9 [ENTER] list all the GPA records more than 3.9
? ~3.0 [ENTER] list all values close to 3.0 with 0.05 precision (between 2.95 and 3.05)
? ! End query
Your program should work under a function called gpaQuery.
gpaQuery
bool gpaQuery(const char* filename);
This function returns false if the filename can not be opened for reading, otherwise, it will return true.
gpaQuery runs as follows:
Data entry:
@2.2
~3.7
~3.8
<2.0
>3.8
~3.9
!
V1.1
sort the output based on student number (stno) in ascending order instead of GPA
Using the above data The function should work as follows:
Enter GPA query...
? @2.2
Syntax error: ? [Op][value]
Op: [>,<,~,!]
value: GPA value
? ~3.7
[1] 231018: 3.7 (Ruth Powers)
[2] 234272: 3.7 (Comic Book Guy)
[3] 362030: 3.7 (Chazz Busby)
[4] 544294: 3.7 (Sea Captain)
? ~3.8
[1] 217994: 3.8 (Selma Bouvier)
? <2.0
[1] 134681: 1.8 (Wise Guy)
[2] 194002: 1.8 (Squeaky-Voiced Teen)
[3] 262592: 1.7 (Barney Gumble)
[4] 383513: 1.7 (Gil Gunderson)
[5] 394769: 1.9 (Troy McClure)
[6] 434336: 1.7 (Seymour Skinner)
[7] 533451: 1.8 (Judge Roy Snyder)
[8] 568727: 1.7 (Kent Brockman)
[9] 584416: 1.7 (Brandine Spuckler)
[10] 667331: 1.9 (Jessica Lovejoy)
[11] 677806: 1.7 (Wendell Borton)
[12] 686009: 1.8 (Helen Lovejoy)
[13] 695606: 1.6 (Kirk Van Houten)
[14] 753102: 1.8 (Bart Simpson)
[15] 877842: 1.6 (Edna Krabappel)
[16] 950955: 1.8 (Snake Jailbird)
? >3.8
[1] 155387: 3.9 (Baby Gerald)
[2] 242653: 3.9 (Bernice Hibbert)
[3] 249669: 4.0 (Ling Bouvier)
[4] 290816: 4.0 (Apu Nahasapeemapetilon)
[5] 324543: 3.9 (Abraham Simpson)
[6] 470546: 4.0 (Agnes Skinner)
[7] 570423: 4.0 (Lindsey Naegle)
[8] 736389: 4.0 (Disco Stu)
[9] 829982: 3.9 (Dolph Starbeam)
[10] 901832: 4.0 (Krusty The Clown)
? ~3.9
[1] 155387: 3.9 (Baby Gerald)
[2] 242653: 3.9 (Bernice Hibbert)
[3] 324543: 3.9 (Abraham Simpson)
[4] 829982: 3.9 (Dolph Starbeam)
? !
Exit the program? (Y)es/(N)o: y
Goodbye!
Modules
Implement your program in three modules:
GPAlist: (must contain the gpaQuery function)
File: hold file-related functions
UI: holding User interaction functions.
Step by Step Solution
3.43 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
It seems like youre asking for assistance with a programming assignment Based on the provided instru...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started