Hi,
I am pretty new to C/C++, and would like some tips on writing the code fo my first 'try' I am trying to write a programme that marks exams and such and calculates grades. I am not looking for somebody to write it for me, well if you want to, haha, but just maybe a point in the right direction, or a few snippits of code to help me along the way. I have a personal tutor who set me this task, and told me to get help where needed, as i want to go into a new career, and want to learn quickly, so your help would be much appreciated. there is a scenario;

Exam and coursework components of the assessment carry a maximum of 50 marks. Pass or fail are determined by:

Combined component total of 40% or more in order to Pass.

Minimum for each component is 15% pass

39% is moderated to 40% and a ‘Moderated Pass’ is awarded.

40% or more overall but minimum component mark not achieved ‘Technical Fai’l of 39% (which is NOT moderated to 40%);

Grades are awarded on marks that fall into the following categories:
Mark - 100-70 69-50 49-40 38-0
Grade - A B C Fail

Thanks in advance for the help.

Which language are you learning, C or C++? (The two languages are very different) and how far have you managed to get with the problem? you're likely to get more useful feedback if you post your attempt at a solution so far.

One way to begin with a task like this is break everything down is to bite-sized pieces. Often it helps to write some kind of informal pseudocode. (If not in a text editor, then on a sheet of paper)

certain parts of the problem should be very straightforward, such as converting a number of marks out of 50 into a percentage.

Other parts of the problem, such as determining the pass/fail status of a student will need a bit more thought - and, depending how much of the language you know, there are different ways you could solve it (You probably want to break the solution down into several functions, to make life easier, and avoid repeating code).

To be honest i don't know to much of the language yet, i jst started learning, it's c++ language, i'm finding it slightly difficult, i have books to help, but i wanted a bit more practical advice, the books help with input of the values, but not so much how to make the programme calculate, i.e. the pass/fail, moderating etc... that seems quite a task to me.

For converting from a mark into a grade, you should look up If/Else blocks in your book.

For other parts of the program, one approach you could use may be to store a true/false value (a boolean value) for whether or not the assessment has been passed.

here's some pseudocode snippets, based on your description of the problem-


Has the student achieved the minimum for both components?

[I]assume the student has passed until we find out they've failed..[/I]
assessment passed = true;
if ( Exam mark is below the threshold OR Coursework mark is below the threshold )
    assessment passed = false
end if

Has the student passed both components and achieved 39%?

if ( assessment passed is true, AND overall mark is 39% )
   adjust overall mark to 40%
end if

Has the student achieved over 40% but failed one of the components?

if ( assessment passed is false, AND overall mark is 40% or more )
   adjust overall mark to 39% 
end if

Try implementing these in C++ - After this, you should be in a position to calculate the final grade.

The best thing you can do is have a go at it and post your code here if you get stuck.

To be honest i don't know to much of the language yet, i jst started learning, it's c++ language, i'm finding it slightly difficult, i have books to help, but i wanted a bit more practical advice, the books help with input of the values, but not so much how to make the programme calculate, i.e. the pass/fail, moderating etc... that seems quite a task to me.

You need to take Bench's advice:

One way to begin with a task like this is break everything down is to bite-sized pieces.

In other words, can you input values correctly? Just do that step. Then move to the next step.

Ask specific questions and post the code that is giving you problems and we can help you correct it.

You probably want to break the solution down into several functions, to make life easier, and avoid repeating code

Just have main() call functions and each function does one step.

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.