Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with this code the main.cpp and GPA.h is already given I need to implement three modules which is File.cpp/File.h, UI.cpp/UI.h and

I need some help with this code the main.cpp and GPA.h is already given I need to implement three modules which is File.cpp/File.h, UI.cpp/UI.h and GPAlist.cpp/GPAlist.h and there's is a sample of the output below. Main.cpp and GPA.h is not to be modified.

Having the following:

- A comma-separated file of student records and their GPA (maximum of 100 records) with the following format:

Student Name, Student number, GPA

Sample:

```text

Abraham Simpson,324543,3.9

Agnes Skinner,470546,4.0

Akira Kurosawa,411928,2.1

Alice Glick,459608,3.3

```

- A header file containing a structure for the GPA record of a student under the name "GPA.h":

```c++

#ifndef SDDS_GPA_H

#define SDDS_GPA_H

struct GPA {

char name[116];

double gpa;

int stno;

};

#endif // !SDDS_GPA_H

```

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:

```text

? [operation][GPA Value]

```

Examples:

```text

? <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

```c++

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 e..;@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:

```text

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.

### Tester program

```c++

MAIN.CPP

#include

#include "GPAlist.h"

using namespace sdds;

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;

}

printf("Goodbye!");

return 0;

}

```

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

need pseudo-code only for in c++ language style pseudo-code \f

Answered: 1 week ago