S
SneakyElf
hi all, im super new with c++ (and no background in programming
whatsoever!)
i have a task to make functions to calculate total profit and the
average number of things sold. data is read from a file. my problem is
with functions, namely setting up parameters and later calling
functions in the main().
here are the two functions (?) that i wrote so far, one is supposed to
get total profit and the other calculate average
#include <iostream>
#include <fstream>
#include <vector>
using std::ifstream;
using namespace std;
double getTotalProfit (double totalProfitOrder, float
profitLossForFreeCookies ) { // what do I set as parameters in this
function?
int freeCookies = 5;
float cookieProductionCost = 0.10;
float profitLossForFreeCookies = freeCookies * cookieProductionCost;
double totalProfitPerOrder = cookiesSoldPerOrder * cookiePrice -
profitLossForFreeCookies;
return totalProfitOrder;
}
double avgNumOfCookiesSold (double avgOfCookieSales, int
cookieOrderCount) {
double avgOfCookieSales;
int totalCookiesOrdered = 0;
int cookieOrderCount = 0;
cookieOrderCount ++;
inData >> cookiesSoldPerOrder;
totalCookiesOrdered += CookiesSoldPerOrder;
avgOfCookieSales = totalCookiesOrdered/cookieOrderCount;
return avgOfCookieSales;
}
i realize my parameters are screwed up, but if you could show me what
i am doing wrong i'd appreciate it.
(for the average i plan on using vectors and dynamically allocated
arrays, but i have trouble setting those up as well - its a mess
really!, however, the setting up functions and calling them is giving
me the most trouble)
any help is greatly appreciated!
whatsoever!)
i have a task to make functions to calculate total profit and the
average number of things sold. data is read from a file. my problem is
with functions, namely setting up parameters and later calling
functions in the main().
here are the two functions (?) that i wrote so far, one is supposed to
get total profit and the other calculate average
#include <iostream>
#include <fstream>
#include <vector>
using std::ifstream;
using namespace std;
double getTotalProfit (double totalProfitOrder, float
profitLossForFreeCookies ) { // what do I set as parameters in this
function?
int freeCookies = 5;
float cookieProductionCost = 0.10;
float profitLossForFreeCookies = freeCookies * cookieProductionCost;
double totalProfitPerOrder = cookiesSoldPerOrder * cookiePrice -
profitLossForFreeCookies;
return totalProfitOrder;
}
double avgNumOfCookiesSold (double avgOfCookieSales, int
cookieOrderCount) {
double avgOfCookieSales;
int totalCookiesOrdered = 0;
int cookieOrderCount = 0;
cookieOrderCount ++;
inData >> cookiesSoldPerOrder;
totalCookiesOrdered += CookiesSoldPerOrder;
avgOfCookieSales = totalCookiesOrdered/cookieOrderCount;
return avgOfCookieSales;
}
i realize my parameters are screwed up, but if you could show me what
i am doing wrong i'd appreciate it.
(for the average i plan on using vectors and dynamically allocated
arrays, but i have trouble setting those up as well - its a mess
really!, however, the setting up functions and calling them is giving
me the most trouble)
any help is greatly appreciated!