I need help with this problem. I have tried writting the program, i just can not get it to run properly.

Please Write a function qualityPoints that inputs a student's average and returns 4 if a student's average is 90 - 100, 3 if the average is 80 - 89, 2 if the average is 70 - 79, 1 if the average is 60 - 69 and 0 if the average is lower than 60.

and thank you

Member Avatar for iamthwee

I need help with this problem. I have tried writting the program, i just can not get it to run properly.

Please Write a function qualityPoints that inputs a student's average and returns 4 if a student's average is 90 - 100, 3 if the average is 80 - 89, 2 if the average is 70 - 79, 1 if the average is 60 - 69 and 0 if the average is lower than 60.

and thank you

int qualityPoints(int s)
{
   if ((s>=90) && (s <=100))
   {
     return 4;
   }
   else if((s>=80) && (s<=89))
   {
     return 3;
   }
   ....etc

Mriamthwee


How are you?
thank you for help me
look this is my tried
put where the error?


#include <iostream.h>
void main ()
{
int s;

if ((s>=90) && (s <=100))
{
return 4;
}
else if((s>=80) && (s<=89))
{
return 3;
}
else if ((s>=70) && (s<=79))
{
return 2;
}
else if ((s>=60) && (s<=69))
{
return 1;
}

}

#include <iostream.h>
void main ()
{
int s;
 
   if ((s>=90) && (s <=100))
   {
     return 4;
   }
   else if((s>=80) && (s<=89))
   {
     return 3;
   }
   else if ((s>=70) && (s<=79))
   {
  return 2;
   }
   else if ((s>=60) && (s<=69))
   {
  return 1;
   }
   
}

First of all, read teh forum guidelines and rules before posting and enclose the code in code tags.

Looks like you must first get ur basics cleared by reading some good tutorials on the web or just google it.

Here are some things u need to change about ur code

>>> #include <iostream.h> Dont use C type includes, make use of C++ styles includes to make avail to urself the power of C++ std library.

>>> void main (void) main returns int not void as a signal to OS about its execution status.
0 on success and anything else on failure.

>>>
YOu have declared a variable int s; but either defined it nor have u taken any input from the user hence it will initially contain garbage value. Somethign like

int s = 89; // defining s

OR

int s;
cout << "Enter the value of s: ";
cin >> s;                                  // getting input from user

>>>

return 1; // this should be return 0;

Returning 1 means the program has encountered some error. A properly executed program returns 0 value.

Hope it helped,
bye.

thaaaaaaaaaaanx

but look===>

Error executing cl.exe.:rolleyes:
xss.exe - 4 error(s), 0 warning(s)

#include <iostream.h>
void main ()
{
int s;
cout<< "Enter the value of s: ";
cin >> s;
if ((s>=90) && (s <=100))
{
return 4;
}
else if((s>=80) && (s<=89))
{
return 3;
}
else if ((s>=70) && (s<=79))
{
return 2;
}
else if ((s>=60) && (s<=69))
{
return 1;
}
}

> xss.exe - 4 error(s), 0 warning(s)

> void main
As well as being wrong (see previous posts, it should be int), you're specifically saying that NO value should be returned.

Yet later on (4 times to be precise), you have a
return 1;
etc.
This isn't void, so the compiler complains.

Oh, and post actual error messages as well so we don't have to guess at what you're seeing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.