Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3021

Calling functions with strings in main is driving me insane

$
0
0
The objective here is to make a program that calculates variables and averages using different functions with strings inside parameters. The program title looks something like this

~Will's car sales has 5 associates that works for him and he wants to award the associate with the highest sales each month with a bonus. The associates names are Jacob, James, Isaiah, Mara and Janice. The program will be written using functions as described below. The program will ask "Will" for the associates 5 sales values and then find the winner of that month's bonus, printing out the name and the month's highest sales. In addition, the program will also output the average sales for the month.~

I understand how to do it but I'm failing to see where to plug things in at. When I ran it the first time it was smooth, but the application of the strings were not getting executed properly, and I ended up combining functions to find two different solutions...Please help me gurus. Source code below is what I got. I wiped the entire thing clean except for the bar essentials, and even then I'm not sure if the strings are correctly put in. The void welcome function is working properly of course.
Code:

#include<iostream>
#include<string>
using namespace std;

//function prototyping
void welcome();
double getNumSales(string salesAssociate);
void findWinner(double jacob, double james, double isaiah, double mara, double janice);
double salesAverage(double jacob, double james, double isaiah, double mara, double janice);

int main()
{
        welcome();

        double Jacob, James, Isaiah, Mara, Janice;
        string jacobsName;
        string jamesName;
        string isaiahsName;
        string marasName;
        string janicesName;

        return 0;
}

void welcome()
{
       
        cout << ("******************************************************************") << endl;
        cout << ("Welcome to Will's Winning Sales Associates Program") << endl;
        cout << ("You will be prompted to enter the number of sales ") << endl;
        cout << ("for each Associate for the month.") << endl;
        cout << ("Please enter a real number for the sales amount.") << endl;
        cout << ("Program Developed by: ") << endl;
        cout << ("*****************************************************************") << endl;
}


double getNumSales(string salesAssociate)
{
        double sales;
       
        cout << "Please enter the sales for " <<salesAssociate<<" this month" << endl;    //ask for sales associate sales for month
        cin >> sales;
       
        if (sales <= 0);
        {
        cout << "Please enter another number" << endl;
        cin >> sales;
        }
       
        return sales;
}

void findWinner(double jacob, double james, double isaiah, double mara, double janice)
{
        //remember tie means no winner
}

double salesAverage(double jacob, double james, double isaiah, double mara, double janice)
{
        //add five sales values then divide by 5

        return 0.0; //fix returned value return average
}


Viewing all articles
Browse latest Browse all 3021

Trending Articles