Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

greater than


  • Please log in to reply

#1
ihatetheworld

ihatetheworld

    New Member

  • Member
  • Pip
  • 6 posts
yes this is for a class o/e, but i am having a hard time on how you would display the greatest sales

ive have asked alot of place but have gotten flamed so any help would be nice thanks.....


#include <iostream>

using namespace std;

double times;

double getQuartlySales( string strDivision )

{



}



int main(int Northeast,int Southeast,int Northwest,int Southwest)

{

// some code to get quartly sales from user
cout << "Enter Quartly sales for each divison."<<endl;

cout << "Northeast:";
cin >> Northeast;
cout << "Southeast:";
cin >> Southeast;
cout << "Northwest:";
cin >> Northwest;
cout << "Southwest:";
cin >> Southwest;


// now we want to return a Q. sales, lets call our function

double d_northeast_sales = getQuartlySales( "Northeast" );





return 0;

}
  • 0

Advertisements


#2
gust0208

gust0208

    Member

  • Member
  • PipPipPip
  • 311 posts
Hello,

It works best if you give your best attempt at a solution then we can help you with your code. It sometimes is annoying people just ask how to do something without making atleast an attempt to try.

Think about what operators or statement you would want to use here. You are going to be comparing four values and I am assuming you have covered IF statements and the > and < comparison operators. That should give you a start.

Cheers,
Tom

yes this is for a class o/e, but i am having a hard time on how you would display the greatest sales

ive have asked alot of place but have gotten flamed so any help would be nice thanks.....
#include <iostream>

using namespace std;

double times;

double getQuartlySales( string strDivision )

{



}



int main(int Northeast,int Southeast,int Northwest,int Southwest)

{

// some code to get quartly sales from user
cout << "Enter Quartly sales for each divison."<<endl;

cout << "Northeast:";
cin >> Northeast;
cout << "Southeast:";
cin >> Southeast;
cout << "Northwest:";
cin >> Northwest;
cout << "Southwest:";
cin >> Southwest;


// now we want to return a Q. sales, lets call our function

double d_northeast_sales = getQuartlySales( "Northeast" );





return 0;

}


  • 0

#3
ihatetheworld

ihatetheworld

    New Member

  • Topic Starter
  • Member
  • Pip
  • 6 posts
yes i understand that people just come on and think that some one will do there homework fro them i have put this together from scratch and we have covered if statements im just lost on using functions. thanks for the reply
  • 0

#4
gust0208

gust0208

    Member

  • Member
  • PipPipPip
  • 311 posts
What questions do you have about functions? The use of functions or the language syntax of them? At the top level, functions are like black boxes. You put in some values and it returns a value. From the main program, you don't know what they are doing, just what they need passed in and what you will be getting in return.

So, for this program. You will likely want a function that takes in the four user-inputted values and returns (or prints) which value was highest.

Also, in the code you posted, it looks as if they want you to use a function to get the user input. The function (getQuartlySales) takes in a string (like 'northwest') and returns a double (I assume the user input). So, roughly the function would look like:
double getQuartlySales( string strDivision )
{
double user_input;
cout << "Enter sales for " + strDivision;
cin >> user_input;
return user_input;
}
Thus this function can be used to get user input for any company. Then your main would look something like this (double-check syntax, I mostly write in Java):

int main(double Northeast,double Southeast,double Northwest,double Southwest)
{
// some code to get quartly sales from user
cout << "Enter Quartly sales for each divison."<<endl;
Northeast = getQuartlySales("Northeast");
Southeast = getQuartlySales("Southeast");
Northwest = getQuartlySales("Northwest");
Southwest = getQuartlySales("Southwest");

// Now, lets find the highest value!
// call your function, something like findHighestSales(ne,se,nw,sw)
// Give a shot writing this function and we can help you get it working
return 0;
}

Hope that helps a bit,
Tom

yes i understand that people just come on and think that some one will do there homework fro them i have put this together from scratch and we have covered if statements im just lost on using functions. thanks for the reply


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP