1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
#include <iostream>
#include <string>
using namespace std;
struct MovieData
{
string title; //Title of movie.
string director; //Director's name.
unsigned int yearReleased; // Year the movie was released.
unsigned int runningTime; //Running time in miuntes.
double productionCost; // Production Cost.
double yearRevenue; // First years revenue.
MovieData(string title, string dir, unsigned int yr, unsigned int rT, double pC, double yR); //Constructor
};
//Define the constructor
MovieData::MovieData(string title, string dir, unsigned int yr, unsigned int rT, double pC, double yR)
{
title = title;
director = dir;
yearReleased = yr;
runningTime = rT;
productionCost = pC;
yearRevenue = yR;
}
void displayMovieInfo(MovieData movieName) //function to display the movie info.
{
cout << "---------------" << endl;
cout << "Title: " << movieName.title << endl;
cout << "Director: " << movieName.director << endl;
cout << "Year Released: " << movieName.yearReleased << endl;
cout << "Running Time: " << movieName.runningTime << "mins" << endl;
cout << "Production Cost: $" << movieName.productionCost << " million" << endl;
cout << "First year Revenues: $" << movieName.yearRevenue << " million" << endl;
cout << "---------------\n" << endl;
}
int main()
{
//Two MovieData variables using the constructor
MovieData movie1("Twilight", "Catherine Hardwicke", 2008, 121,37, 392);
MovieData movie2("The Watchmen- Director's Cut", "Zack Snyder", 20, 186, 120, 55.7);
//Displaying the movie info using the displayMovieInfo() function
displayMovieInfo(movie1);
displayMovieInfo(movie2);
system("pause");
system("cls");
}
struct CorpData
{
string divisionName;
double firstQuarterSales;
double secondQuarterSales;
double thirdQuarterSales;
double fourthQuarterSales;
double totalSales;
double averageQuarterlySales;
CorpData(string dN, double fQS,double sQS, double tQS, double forQS, double aQS,double tS); //Contructor.
};
//Define the constructor.
CorpData::CorpData(string dN, double fQS, double sQS, double tQS, double forQS, double aQS, double tS)
{
divisionName = dN;
firstQuarterSales = fQS;
secondQuarterSales = sQS;
thirdQuarterSales = tQS;
fourthQuarterSales = forQS;
averageQuarterlySales = aQS;
totalSales = tS;
}
//Function.
void displayCorpInfo(CorpData corpName)
{
cout << "-----------------------------------" << endl;
cout << endl;
cout << "Division Name: " << corpName.divisionName << endl;
cout << "First Quarter Sales; $" << corpName.firstQuarterSales << endl;
cout << "Second Quater Sales: $" << corpName.secondQuarterSales << endl;
cout << "Third Quarter Sales: $" << corpName.thirdQuarterSales << endl;
cout << "Fourth Quarter Sales: $" << corpName.fourthQuarterSales << endl;
cout << "Average Quarterly Sales: $" << corpName.averageQuarterlySales <<endl;
cout << "Total Annual Average: $" << corpName.totalSales << endl;
cout << endl;
cout <<"------------------------------------" << endl;
}
int main()
{
//CorpData variables using the constructor.
CorpData div1("North Division", 25000, 54543, 67890, 54987, 50605, 202420);
CorpData div2("South Division", 56098, 23456, 12345, 34543, 31610.50, 126442);
CorpData div3("West Division", 34567, 54321, 98765, 78987, 66660, 266640);
CorpData div4("East Division", 54678, 43123, 12345, 34567, 36178.25, 144713);
//Display the Copr info using displayCorpInfo() function.
displayCorpInfo(div1);
displayCorpInfo(div2);
displayCorpInfo(div3);
displayCorpInfo(div4);
system("pause");
return 0;
}
|