Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Program Files for Assignment6 (provided) and redo this program so that it uses (i) the STL list and (ii) the STL queue. #include

Please use Program Files for Assignment6 (provided) and redo this program so that it uses (i) the STL list and (ii) the STL queue.

#include #include #include #include #include "myStack.h"

using namespace std;

int main() { //Step 1 double GPA; double highestGPA; string name;

stackType stack(100);

ifstream infile;

infile.open("HighestGPAData.txt"); //Step 2

if (!infile) //Step 3 { cout << "The input file does not " << "exist. Program terminates!" << endl; return 1; }

cout << fixed << showpoint; //Step 4 cout << setprecision(2); //Step 4

infile >> GPA >> name; //Step 5

highestGPA = GPA; //Step 6

while (infile) //Step 7 { if (GPA > highestGPA) //Step 7.1 { stack.initializeStack(); //Step 7.1.1

if (!stack.isFullStack()) //Step 7.1.2 stack.push(name);

highestGPA = GPA; //Step 7.1.3 } else if (GPA == highestGPA) //Step 7.2 if (!stack.isFullStack()) stack.push(name); else { cout << "Stack overflows. " << "Program terminates!" << endl; return 1; //exit program } infile >> GPA >> name; //Step 7.3 }

cout << "Highest GPA = " << highestGPA << endl; //Step 8 cout << "The students holding the " << "highest GPA are:" << endl;

while (!stack.isEmptyStack()) //Step 9 { cout << stack.top() << endl; stack.pop(); }

cout << endl;

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

Step: 3

blur-text-image

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago