Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Need help sorting an array: these two functions pull data and put it into an array. I need to run loadmovies and sort the

C++ Need help sorting an array: these two functions pull data and put it into an array.

I need to run loadmovies and sort the array based on movies[i].expectedYield (ie 0,1 or 2), and then add the data from LoadRooms

void LoadMovies(Movie movies[]){ //loads movie data from file

int numMovies;

ifstream infile; infile.open("movies.txt"); infile>>numMovies;

for(int i=0; i>movies[i].title; infile>>movies[i].runTime; infile>>movies[i].expectedYield; }

infile.close(); }

void LoadRooms(Movie movies[], int size){ //loads room data from file. ifstream infile; infile.open("rooms.txt");

for(int i=0; i>movies[i].roomID; infile>>movies[i].capacity; movies[i].available = movies[i].capacity;; //initial availability is equal to capacity as no tickets are sold } infile.close(); }

movies.txt

9 Gemini_Man 117.9 2 Joker 122.8 2 Zombieland 99.5 2 Knives_Out 130.1 1 Judy 118.3 0 Downton_Abbey 123.8 0 It 170.0 2 Black_and_Blue 108.4 1 Terminator_Dark_Fate 134.9 1

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

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions