Hi There,

I'm learning C++. One of the questions requires a function to do a calculation below. I have no clue how to do this. Can anybody help?

WeTryToHelp gives bursaries to help students with buying their textbooks. The amount of money depends on how
many modules the student passed during 2007 and for how many modules the student is registered in 2008. It works
as follows:
• if the student did not pass any modules in 2007: no bursary,
• if the student passed 1 or 2 modules in 2007 and is registered for at least 1 module in 2008: R300,
• otherwise: the bursary is equal to (number of modules passed + number of modules registered) * 100.
Three examples: If the student passed 4 modules in 2007 and is registered for 5 modules in 2008, the bursary will be
R900. If the student passed 2 modules in 2007 and is registered for 5 modules in 2008, the bursary will be R300. If
the student did not pass any modules in 2007 and is registered for 5 modules in 2008, no bursary will be given.

Recommended Answers

All 2 Replies

This is not a free homework service. You'll have to show some effort before you get help. So post what you've done so far.
Or ask specific questions

Fair enough. Here is the code

#include <iostream>
using namespace std;
//modP is the passed modules and modR is registered modules
float bursary(float modP, float modR)
{
   float burs;  
  {if (modP == 0)         
       burs = 0;
   else if (modP == 1 && modR >= 1)
          burs = (modP * 300);
   else
       burs = ((modP + modR)*100);
  } 
  
  return burs;
}
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.