(Solved Homework): 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:

Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): There is a file of a few movies that contains the following data:…
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

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;
}

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

Homework Ocean
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

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.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents