Answered Essay: There is a file of a few movies that contains the following data:

c++ programming

There is a file of a few movies that contains the following data:

Date of release
Movie name
Production cost
Gross profit

Your assignment is: for each movie,

1. Without changing the data, read in the Date of release,
the Movie name, the Production cost and the Gross profit
for all of the movies and put the information into an
array of structs (or classes).
2. Sort the array of movies by Movie Name alphabetically
3. Print the array of movies with a heading.
The fields should be printed in the following order:
Movie Name, Release Date, Production cost and Gross profit
4. Sort the array of movies by Percent Profit (Gross profit/Production Cost)
3. Print the array of movies with a heading.
The fields should be printed in the following order:
Movie Name, Production cost, Release Date and Percent Profit

//input file

11111

11111111112222222222333333333344444444445555555555666666666677777777778888888888999999999900000

12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234

Release Date         Movie                                   Production Budget        Worldwide Box Office

Dec 15, 1939         Gone with the Wind                         $3,900,000                  $390,525,192

Jun 4, 1982          Poltergeist                               $10,700,000                  $121,706,019

Feb 9, 2001          Hannibal                                  $87,000,000                  $350,100,000

Mar 23, 2001         Heartbreakers                             $38,000,000                   $57,753,825

Aug 3, 2001          Original Sin                              $26,000,000                   $16,521,410

Jun 14, 2002         Windtalkers                              $115,000,000                   $77,628,265

Mar 14, 2003         Agent Cody Banks                          $25,000,000                   $58,240,458

Apr 15, 2005         The Amityville Horror                     $18,500,000                  $108,800,304

Mar 16, 2007         Premonition                               $20,000,000                   $81,461,343

Feb 22, 2008         Charlie Bartlett                          $12,000,000                    $5,295,909

Dec 25, 2008         Valkyrie                                  $90,000,000                  $203,902,107

Jun 12, 2009         The Taking of Pelham 123                 $110,000,000                  $152,364,370

Jul 8, 2011          Zookeeper                                 $80,000,000                  $170,805,525

Dec 20, 2011         The Girl with the Dragon Tattoo           $90,000,000                  $239,373,970

Mar 16, 2012         21 Jump Street                            $42,000,000                  $202,812,429

Aug 8, 2012          Hope Springs                              $30,000,000                  $115,849,781

Nov 8, 2012          Skyfall                                  $200,000,000                $1,110,526,981

Dec 14, 2012         The Hobbit: An Unexpected Journey        $250,000,000                $1,017,003,568

Jan 25, 2013         Hansel & Gretel: Witch Hunters            $50,000,000                  $214,949,716

Mar 27, 2013         G.I. Joe: Retaliation                    $140,000,000                  $371,923,060

Oct 18, 2013         Carrie                                    $30,000,000                   $82,409,520

Jun 13, 2014         22 Jump Street                            $50,000,000                  $331,333,876

Dec 17, 2014         The Hobbit: The Battle of the 5 Armies   $250,000,000                  $955,119,788

Feb 20, 2015         Hot Tub Time Machine 2                    $14,000,000                   $12,452,601

May 8, 2015          Hot Pursuit                               $35,000,000                   $45,680,201

11111

11111111112222222222333333333344444444445555555555666666666677777777778888888888999999999900000

12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234

Release Date         Movie                                   Production Budget        Worldwide Box Office

Dec 15, 1939         Gone with the Wind                         $3,900,000                  $390,525,192

Jun 4, 1982          Poltergeist                               $10,700,000                  $121,706,019

Feb 9, 2001          Hannibal                                  $87,000,000                  $350,100,000

Mar 23, 2001         Heartbreakers                             $38,000,000                   $57,753,825

Aug 3, 2001          Original Sin                              $26,000,000                   $16,521,410

Jun 14, 2002         Windtalkers                              $115,000,000                   $77,628,265

Mar 14, 2003         Agent Cody Banks                          $25,000,000                   $58,240,458

Apr 15, 2005         The Amityville Horror                     $18,500,000                  $108,800,304

Mar 16, 2007         Premonition                               $20,000,000                   $81,461,343

Feb 22, 2008         Charlie Bartlett                          $12,000,000                    $5,295,909

Dec 25, 2008         Valkyrie                                  $90,000,000                  $203,902,107

Jun 12, 2009         The Taking of Pelham 123                 $110,000,000                  $152,364,370

Jul 8, 2011          Zookeeper                                 $80,000,000                  $170,805,525

Dec 20, 2011         The Girl with the Dragon Tattoo           $90,000,000                  $239,373,970

Mar 16, 2012         21 Jump Street                            $42,000,000                  $202,812,429

Aug 8, 2012          Hope Springs                              $30,000,000                  $115,849,781

Nov 8, 2012          Skyfall                                  $200,000,000                $1,110,526,981

Dec 14, 2012         The Hobbit: An Unexpected Journey        $250,000,000                $1,017,003,568

Jan 25, 2013         Hansel & Gretel: Witch Hunters            $50,000,000                  $214,949,716

Mar 27, 2013         G.I. Joe: Retaliation                    $140,000,000                  $371,923,060

Oct 18, 2013         Carrie                                    $30,000,000                   $82,409,520

Jun 13, 2014         22 Jump Street                            $50,000,000                  $331,333,876

Dec 17, 2014         The Hobbit: The Battle of the 5 Armies   $250,000,000                  $955,119,788

Feb 20, 2015         Hot Tub Time Machine 2                    $14,000,000                   $12,452,601

May 8, 2015          Hot Pursuit                               $35,000,000                   $45,680,201

Expert Answer

 

//main.cpp

//program pairs with movie.file
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <iomanip>
using namespace std;

struct info {
string release;
string title;
string budget;
string box;
double b;
double bo;
};

void delete_chars(string & st, char ch) {

int i = st.find(ch);
while(i > -1) {
st.replace(i, 1, “”);
i = st.find(ch);
}

}

int main() {
string st, re, tit;
string bud, bx;
int d, x;
info list[26];

//imports file into struct fields
for(int i = 0; i < 26; i++) {

getline(cin, st);

re = st.substr(0, 12);
tit = st.substr(20, 39);
bud = st.substr(60, 18);
bx = st.substr(85, 21);

delete_chars(bud, ‘$’);
delete_chars(bud, ‘,’);
delete_chars(bx, ‘$’);
delete_chars(bx, ‘,’);

list[i].release = re;
list[i].title = tit;
list[i].budget = bud;
list[i].box = bx;
}

cout << “The list of films unsorted” << endl;
cout << “—————————————————————————————–” << endl;
cout << endl;

//prints the file from struct fields
for(int j = 0; j < 26; j++) {

cout << list[j].release << ” ” << list[j].title
<< ” ” << list[j].budget << ” ”
<< list[j].box << endl;
}

cout << “—————————————————————————————–” << endl;

int size = 26;

//converts strings into floating point numbers
//and then copies values into another struct field
for(int f = 1 ; f < size; f++) {

list[f].b = atof(list[f].budget.c_str());
list[f].bo = atof(list[f].box.c_str());
}

//Sorts file by film title
int swaps = 1;
size = 26;

while(swaps) {

swaps = 0;

for(int x = 1; x < size – 1; x++) {

if(list[x].title > list[x + 1].title) {

swap(list[x], list[x + 1]);
swaps = 1;
}
}
}

//Prints sorted fields
cout << setprecision(2) << fixed;
cout << endl;
cout << “Sorted by title” << endl;
cout << “—————————————————————————————–” << endl;
cout << endl;
cout << list[0]. title
<< setw(15) << right
<< list[0].release
<< setw(20) << right
<< list[0].budget
<< setw(15) << right
<< list[0].box << endl;

for(int y = 1; y < 26; y++) {

cout << list[y].title
<< setw(15) << right
<< list[y].release
<< setw(20) << right
<< list[y].b
<< setw(15) << right
<< list[y].bo << endl;
}

cout << “—————————————————————————————–” << endl;

//sorts fields by percent profit
swaps = 1;

while(swaps) {

swaps = 0;

for(int e = 1; e < size – 1; e++) {

if(list[e].bo / list[e].b < list[e + 1].bo / list[e + 1].b) {

swap(list[e], list[e + 1]);
swaps = 1;
}
}
}

//prints sorted fields
cout << endl;
cout << “Sorted by profit” << endl;
cout << “—————————————————————————————–” << endl;
cout << endl;
cout << list[0]. title
<< setw(15) << right
<< list[0].release
<< setw(20) << right
<< list[0].budget
<< setw(15) << right
<< list[0].box << endl;

for(int y = 1; y < 26; y++) {

cout << list[y].title
<< setw(15) << right
<< list[y].release
<< setw(20) << right
<< list[y].b
<< setw(15) << right
<< list[y].bo << endl;
}

cout << “—————————————————————————————–” << endl;
}

========================================================================

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?