473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using Function

Hey Guys,

Can you help me understand this concept? I am trying to use function
qualityPoints here to return a value of 4 if an average is 90-100, 3 if it
is 80-90, 2 if its 70-80, 1 if its 60-70 and 0 if it drops below 60. I am
learning functions and trying to figure out what values should be between
the parentheses in the initializing phase, and also how it should be
written. I am on a mental block on this one. Here's what I have so far:

//Program returns the GPA based on student average

include <iostream>

include <cmath>

using std::cout;

using std::cin;

using std::end1;

int qualityPoints ( int, int, int, int, int, int )

int main() //function main begins program execution

{

int average; //student average

int GPA; //grade point average

cout << "Enter the student's average:";

cin >> average;

cout << "Grade Point Average Is:";

<< qualityPoints ( GPA ) << end1;

getch (); //indicates successful termination

}

//function qualityPoints definition

int qualityPoints (

Thanks for your help!


Jul 23 '05 #1
4 2080
Keith wrote:
Can you help me understand this concept? I am trying to use function
qualityPoints here to return a value of 4 if an average is 90-100, 3
if it is 80-90, 2 if its 70-80, 1 if its 60-70 and 0 if it drops
below 60. I am learning functions and trying to figure out what
values should be between the parentheses in the initializing phase,
and also how it should be written. I am on a mental block on this
one. Here's what I have so far:
//Program returns the GPA based on student average

[..nothing of substance..]


We don't do homeworks. However, here is a hint: given a value of the
average, compare it to 90, if it's greater or equal, return 4, if not,
compare it to 80, and so on.

V
Jul 23 '05 #2
Yeah, I'm not looking for someone to do it, just help me appreciate the
concept of functions, I can't get how they should be laid out.
Jul 23 '05 #3
Keith wrote:
Yeah, I'm not looking for someone to do it, just help me appreciate
the concept of functions, I can't get how they should be laid out.


You'll find as many opinions about that as you'll hear voices. What
does the C++ book you're using to study, says?
Jul 23 '05 #4
Keith wrote:
Hey Guys,
[snip requirements]
//Program returns the GPA based on student average

include <iostream>

include <cmath>

using std::cout;

using std::cin;

using std::end1;

int qualityPoints ( int, int, int, int, int, int )

Why do you have so many parameters here to be sent to qualityPoints ?
Right now you are provinding 6 ints. This is same as 6 input values.
But, as far as I understood your problem you just need to give as input
the average which you have already asked the user. Soo, to start with
you just need to give 1 input or only 1 int so your above line should
be:

int qualityPoints (int);

Now let us know how would you do this in real life if say your next
door neighbor tells you that he has got 76 as average. Another neighbor
tells you she got 85. You would simply have the table in front of you
and tell him/her their Gade Point Average.

Try it yourself and ask as many questions as you want but give it a
shot.

int main() //function main begins program execution

{

int average; //student average

int GPA; //grade point average

cout << "Enter the student's average:";

cin >> average;

cout << "Grade Point Average Is:";

<< qualityPoints ( GPA ) << end1;

getch (); //indicates successful termination

}

//function qualityPoints definition

int qualityPoints (

Thanks for your help!


Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Daniel | last post by:
Hello =) I have an object which contains a method that should execute every x ms. I can use setInterval inside the object construct like this - self.setInterval('ObjectName.methodName()',...
1
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
3
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look...
9
by: Ron | last post by:
Hello, Is it required to use Imports System.Runtime.InteropServices to run C++ API code? I ask because I thought I read somewhere that this was required. If it is not required would it...
14
by: B Williams | last post by:
I am stuck on an assignment that uses classes and functions. I am receiving numerous errors when I try to run a test program to see if I wrote it correctly. Can someone please point me in the right...
2
by: Tugrul HELVACI | last post by:
I'm using Delphi 2006 and I have a class defination like this: TPerson = class fPersonName : String; fPersonSurName : String; fPersonAge : Integer; published property PersonName : String...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.