473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Write C++ program that calculate students CGPA and store in to file name

4
#include<fstream>
#include<iostream>
#include<string>
using namespace std;
class student{
private:
string fname;
string lname ;
char sex;
string id;
char grade[20];
int year;
int semester;
int ncourse ;
string coursename[20];
int crhr[20];
int coursecrhr[20] ;
int totalcrhr = 0;
int point[20];
int totalpoint = 0;
double cpga;
public:
void acceptdata(){
cout
Jan 16 '15 #1

✓ answered by weaknessforcats

Start over.

First get a data model:

A student has a first and last name, an ID (maybe sex but that might be illegal). That's it.

Then you need a course class. It has a course name, ID, credit hours.

Then you need instructor class. It has the instructor name, instructor ID.

Then you need a curriculum class. Here is where you create a curriculum for the student. Here you enter the classes the student takes, the instructor that taught the class, the final grade.

Now you can calculate the CGPA by getting the hours and the grade from the curriculum class for a specific student ID. Use the Student ID to get the student name. Use the instructor ID to get the instructor name, use the course ID to get the course name.

Get all this working before you worry about a file name.

Remember class members are HAS properties of the class. Like a student HAS a name. So a name is valid for a student. But a student does not have a grade. So grade is not part of the student class.

Read up on the HAS-A model for class members.

2 13462
weaknessforcats
9,208 Expert Mod 8TB
Start over.

First get a data model:

A student has a first and last name, an ID (maybe sex but that might be illegal). That's it.

Then you need a course class. It has a course name, ID, credit hours.

Then you need instructor class. It has the instructor name, instructor ID.

Then you need a curriculum class. Here is where you create a curriculum for the student. Here you enter the classes the student takes, the instructor that taught the class, the final grade.

Now you can calculate the CGPA by getting the hours and the grade from the curriculum class for a specific student ID. Use the Student ID to get the student name. Use the instructor ID to get the instructor name, use the course ID to get the course name.

Get all this working before you worry about a file name.

Remember class members are HAS properties of the class. Like a student HAS a name. So a name is valid for a student. But a student does not have a grade. So grade is not part of the student class.

Read up on the HAS-A model for class members.
Jan 16 '15 #2
Dizzy
4
Help me !! what is wrong in this code the program should calculate and display two students information in that users has entered .

#include<fstream>
#include<iostream>
#include<string>
using namespace std;
class student{
private:
string name ;
char sex;
string id;
char grade[20];
int year;
int semester;
int ncourse ;
string coursename[20];
int crhr[20];
int coursecrhr[20] ; int totalcrhr = 0;
int point[20];
int totalpoint = 0;
double cpga;
public:
void acceptdata(){
cout<<"Enter year:";
cin>>year;
cout<<"Enter semester: ";
cin>>semester;
cout<<"Enter the number of course :";
cin>>ncourse;
for(int i=0,i>=2,++i){
cout<<"Student name:";
cin>>name;
cout<<"Student sex:";
cin>>sex;
cout<<"student id:";
cin>>id;
}
for(int coursename=0,coursename>=3,++coursename){
cout<<"course name:"
cin>>coursename;
cout<<course credit hour:";
cin>>crhr;
}
for(int grade=0,grade>=3,++grade){
cout<<"Grade for :"<<coursename<<endl;
cin>>grade;
}
if(point>=95)
{return A}
else if(point>=80)
{return B}
else if(point>=70)
{return C}
else if(point>=60)
{return D}
else
{return F}
void datacal(){

}
int main()
{
student s,s1;
student s.void acceptdata()
student s.void datacal()
student s1.void acceptdata()
student s1.void datacal()
return 0;
}
Jan 18 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: simpsoro | last post by:
I am trying to run asp.net pages. The server is accessed by students via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and...
3
by: cjw | last post by:
I have a c++ program,it takes a BMP file and do some operations on the file. What I want to know is how to get the file name automatically and run the program in batch mode as I have to run this...
10
by: Ben Finney | last post by:
Howdy all, Question: I have Python modules named without '.py' as the extension, and I'd like to be able to import them. How can I do that? Background: On Unix, I write programs intended to...
5
by: tcwarrior | last post by:
Hi all. I am trying to write a little program where I extract some data out of a game in real time. The game writes some info to a log file, and I can access this in real time. The problem is that...
4
by: carmelo | last post by:
Hi! I need to read and store data from a file, but I don't the name of it; Is this code correct and is there a better way to do this thing?? int main() { cout << " type file name:" char *...
16
by: John | last post by:
I am looking for VBA code that will work with Access 2003 to enable dragging and dropping a file/folder name from Windows XP Explorer into an Access form's text box. This is a common functionality...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
9
by: Bill David | last post by:
I know it's very strange to do that since we have the file name when we call: int open(const char *pathname, int oflag,...); And we can store the file name for later usage. But I just wonder if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.