[C++]
Please help to understand why this code need to have "void calcSales(CorpData &);" and "void displayDivInfo(CorpData);". Thanks!
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <string>
using namespace std;
struct CorpData
{
string diviName;
double firstQua, secondQua, thirdQua, fourthQua, annualSales,
quaAvg;
CorpData(string d, double fq, double sq, double tq, double
frq)
{
diviName = d;
firstQua = fq;
secondQua = sq;
thirdQua = tq;
fourthQua = frq;
}
};
void calcSales(CorpData &);
void displayDivInfo(CorpData);
int main()
{
CorpData West("West", 10000, 20000, 30000, 40000);
CorpData East("East", 90000, 100000, 110000, 0);
CorpData North("North", 50000, 60000, 70000, 80000);
CorpData South("South", 120000, 130000, 140000, 150000);
calcSales(West);
calcSales(East);
calcSales(North);
calcSales(South);
displayDivInfo(West);
displayDivInfo(East);
displayDivInfo(North);
displayDivInfo(South);
return 0;
}
void calcSales(CorpData &d)
{
d.annualSales = d.firstQua + d.secondQua + d.thirdQua +
d.fourthQua;
d.quaAvg = d.annualSales/4;
}
void displayDivInfo(CorpData d)
{
cout << "Division name: " <<
d.diviName << endl;
cout << "Annual Total: $" << d.annualSales
<< endl;
cout << "Annual Quarterly: $" <<
d.quaAvg;
cout << endl;
cout << endl;
}
Note: Could you plz go through this explanation which I
provideed and let me know if u need more explanation
=================================
Note :
In C++ , we have to declare the function headers before the main() function when we want to provide any functions in the c++.For the function headers which we declared before the main() function we have to provide the function implemenattion after the main() function.
=========================================
#include <iostream>
#include <string>
using namespace std;
// Declaring Struct Named CorpData
struct CorpData
{
// Declaring varibales
string diviName;
double firstQua, secondQua, thirdQua, fourthQua, annualSales,
quaAvg;
CorpData(string d, double fq, double sq, double tq, double
frq)
{
diviName = d;
firstQua = fq;
secondQua = sq;
thirdQua = tq;
fourthQua = frq;
}
};
// Function declarations
void calcSales(CorpData &);
void displayDivInfo(CorpData);
// main() function
int main()
{
CorpData West("West", 10000, 20000, 30000, 40000);
CorpData East("East", 90000, 100000, 110000, 0);
CorpData North("North", 50000, 60000, 70000, 80000);
CorpData South("South", 120000, 130000, 140000, 150000);
calcSales(West);
calcSales(East);
calcSales(North);
calcSales(South);
displayDivInfo(West);
displayDivInfo(East);
displayDivInfo(North);
displayDivInfo(South);
return 0;
}
/* Function implementation which will calculate
* and return the average of 4 quarters sales of CorpData
*/
void calcSales(CorpData &d)
{
d.annualSales = d.firstQua + d.secondQua + d.thirdQua +
d.fourthQua;
d.quaAvg = d.annualSales/4;
}
/* Function implementation which will display
* the information of CorpData
*/
void displayDivInfo(CorpData d)
{
cout << "Division name: " << d.diviName <<
endl;
cout << "Annual Total: $" << d.annualSales <<
endl;
cout << "Annual Quarterly: $" << d.quaAvg;
cout << endl;
cout << endl;
}
===============================================
Output:
==================================Thank You
[C++] Please help to understand why this code need to have "void calcSales(CorpData &);" and "void...
guys need help please im super lost anyone save me do programming exercise top_div_array.cpp: Winning Division app (top_div.cpp) revisited to use arrays This is the same program done last week but using and passing arrays instead of individual variables. Start with the following file / cODE BELOW: // Name: top_div_array.cpp // Description: // This app inputs sales for four regional division and displays the highest. // To accomplish this, use two arrays of equal length - one for sales and...
I need to add something to this C++ program.Additionally I want it to remove 10 words from the printing list (Ancient,Europe,Asia,America,North,South,West ,East,Arctica,Greenland) #include <iostream> #include <map> #include <string> #include <cctype> #include <fstream> #include <iomanip> using namespace std; void addWord(map<std::string,int> &words,string s); void readFile(string infile,map<std::string,int> &words); void display(map<std::string,int> words); int main() { // Declaring variables std::map<std::string,int> words; //defines an input stream for the data file ifstream dataIn; string infile; cout<<"Please enter a File Name :"; cin>>infile; readFile(infile,words);...
//Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; class googlePlayApp { private: string name; double rating; int numInstalls; int numReviews; double price; public: googlePlayApp(string, double, int, int, double); ~ googlePlayApp(); googlePlayApp(); string getName(); double getRating(); int getNumInstalls(); int getNumReviews(); string getPrice(); void setName(string); void setRating(double); void setNumInstalls(int); void setNumReviews(int); void setPrice(double); }; googlePlayApp::googlePlayApp(string n, double r, int ni, int nr, double pr)...
Please Help. C++. Need 3 attributes and 3 methods added to the code below. Need the prototype added to the .h file......and the implementation in the .cpp file....thanks! edited: I just need the above and then I was told to use the methods in the main program; for the vehicle. Any 3 attributes and any three methofds. source.cpp file // Header Comment #include #include #include #include "Automobile.h" using namespace std; struct Address{ string street; string city; string state; string zip;...
I need help modifying this code please ASAP using C++ Here is what I missed on this code below Here are the instructions Here is the code Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...
Need help in C++ #include <bits/stdc++.h> using namespace std; // Complete the fly function below. void fly(string commands) { } int main() { string commands; getline(cin, commands); fly(commands); return 0; } • "N" instructs the drone to move north 1 space - for example, from (0,0) to (0,1). • "S" instructs the drone to move south 1 space. • "E" instructs the drone to move east 1 space. • "W" instructs the drone to move west 1 space. The commands...
using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...
Please help with my car traffic simulator! Code that I already have below, I do not know how to start it off! public class IntersectionSimulation { private final static int EAST_WEST_GREEN_TIME = 30 ; private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ; private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ; private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ; private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...