My program crashes as soon as it is run.
I am using windows 7 home premium,
IDE - Bloodshed dev c++
Design and implement a c++ class called "Module" that handles information regarding your assignmentsfor a specific module. Think of all the things you would want to do with such a class and write corresponding member functions for your Module class.
Write a main program that does the following:
*Declare an array of all your modules. The elements of the array must be of type Module.
*initialise the array with the modules you are registered for. Initialise each module with the assignment marks you have obtained for the module
*Determine your semester mark for each module; first assignment contributes 30% and second assignment contributes 70%
*Adjust the marks for assignment2 by +5%
*Determine your semester mark again.
*Display a list of your semester marks for all the modules
This is a question in my textbook.
I have not finished the entire program but I wanted to sort out the crashing problem before I continued, I think the remainder of my program should be quite easy to accomplish if I fix the crashing.
Any help r pointers are appreciated.
Oh and I have been doing c++ for about 4 months. It's my first language I am learning.
class Module
{
public:
//Initialize the private variables.
Module();
//output the module names to the screen
void output();
//Prompts the user to enter the modules they are taking.
void setModules();
//Sets the marks obtained per module
void setModuleMarks();
private:
string subject[];
int total[];
int count;
int firstMark;
int secondMark;
};
int main()
{
Module modules;
Module();
modules.setModules();
modules.setModuleMarks();
modules.output();
system("PAUSE");
return 0;
}
Module::Module()
{
//Ideally create a loop to initialize these values
subject[0] = "";
subject[1] = "";
subject[2] = "";
subject[3] = "";
firstMark = 0;
secondMark = 0;
//Ideally create a loop to initialize these values
total[0] = 0;
total[1] = 0;
total[2] = 0;
total[3] = 0;
}
//Output the moudles stored in the array of subjects and array of total.
void Module::output()
{
for (int i = 0; i < count; i++)
{
cout << subject[i] << " " << total[i] << endl;
}
}
//Prompts the user to enter the data.
void Module::setModules()
{
string module = "";
count = 0;
do
{
cout << "Please enter your module or -1 to exit: " << endl;
cin >> module;
//Prompts the user to enter marks scored for the modules registered.
void Module::setModuleMarks()
{
for (int i = 0; i < count; i++)
{
cout << "Please enter the first mark obtained for module " << subject[i] << ": ";
cin >> firstMark;
cout << "\nPlease enter the second mark obtained for module " << subject[i] << ": ";
cin >> secondMark;