Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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