can someone help me write this short programme I am newby...

Create a class Student that will have private attributes string name, string last name, string datebirth, double average grade.

This class must have a constructor without parameters (in which all string attributes are set to an empty string, and numeric attributes to 0) and a constructor with three parameters (string name, string last name, string date_birth) in which string attributes are set to values ​​sent through parameters, and numeric attributes to 0.

It is necessary to make methods:

void ChangeBasicData () within which to enter the value entered name, surname and date of birth by the user and assign these entered values ​​to the attributes

void CalculateAverageRate () within which it is necessary to enter 5 grades (1-5) and calculate their average, and place this value in the appropriate attribute of the class. It is up to you to determine how you will calculate the average grade, whether you want to create a string and enter and then take grades from it for calculation or use a variable as the sum that you will divide later, it doesn't matter. What is important for this method is that you must throw an exception if an invalid value is entered for the evaluation. So the correct values ​​for the rating are (1,2,3,4,5) and every other entry should cause an exception to be thrown. You will "catch" this exception in the main, ie. at the point where you invoke this method. So if you have option 2 in the interactive menu which is Calculate Average Rating, in it you will have a try block where you call this method and then a catch block where you can print the message "You did not enter the correct data. Next time be more careful!" and return to the user the home menu where he selects options.

void PrintsData () within which all data for a student will be printed, e.g.

Student Name: John

Student surname: Isner

Date of birth of student: 07.07.2007

Average student grade: 4.42

Recommended Answers

All 4 Replies

here it is

#include <iostream>
using namespace std;

class Student
{
private:
     string name;
     string surname;
     string date_birth;
     double average_ grade;

public:
     Student ()
     {
         name = "";
         last name = "";
         date_birth = "";
         average_ Grade = 0;
     }
};

int main ()
{
     return 0;
}

I see this was marked as solved.

yes

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.