473,396 Members | 1,758 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,396 software developers and data experts.

I need help how to add a subject code in this coding.

1 Bit
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. #include <limits>
  5.  
  6. using namespace std;
  7.  
  8. class student
  9. {
  10.     string name;
  11.     string id;
  12.     int credit[46];
  13.     float pointer[46];
  14.     float gpa[8];
  15.     float totalCredit;
  16.     float cgpa=0;
  17.     float sumTotalCredit;
  18.     float credpoint;
  19.     int sem, currentSub;
  20.     float x;
  21.     float sumCredPoint;
  22.  
  23.     public:
  24.  
  25.     float getTotalCredit()
  26.     {
  27.         return totalCredit;
  28.     }
  29.  
  30.     void setTotalCredit(float t)
  31.     {
  32.         totalCredit=t;
  33.     }
  34.  
  35.     float getSumTotalCredit()
  36.     {
  37.         return sumTotalCredit;
  38.     }
  39.  
  40.     void setSumTotalCredit(float c)
  41.     {
  42.         sumTotalCredit=c;
  43.     }
  44.  
  45.     float CalculateGpa(float i,int k){
  46.  
  47.         return i/k;
  48.     }
  49.  
  50.     float getCredPoint()
  51.     {
  52.         return credpoint;
  53.     }
  54.  
  55.     void setCredPoint(float r)
  56.     {
  57.         credpoint=r;
  58.     }
  59.     float getCurrentSub()
  60.     {
  61.         return currentSub;
  62.     }
  63.  
  64.     void setCurrentSub(int s)
  65.     {
  66.         currentSub=s;
  67.     }
  68.  
  69.     float getSumCredPoint()
  70.     {
  71.         return sumCredPoint;
  72.     }
  73.  
  74.     student(string name,string id)
  75.     {
  76.         this->name=name;
  77.         this->id=id;
  78.     }
  79.  
  80.     string getName()
  81.     {
  82.         return name;
  83.     }
  84.  
  85.         string getId()
  86.     {
  87.         return id;
  88.     } };
  89.  
  90.         int main()
  91.         {
  92.     /*system("color 07");
  93.      cout<<"\n\n\n\tPlease wait while loading ..\n\n";
  94.      char a=177, b=219;
  95.     cout<<"\t      ";
  96.     for (int i=0;i<=12;i++)
  97.     cout<<a;
  98.     cout<<"\r";
  99.      cout<<"\t      ";
  100.      for (int i=0;i<=12;i++)
  101.      { cout<<b;
  102.       for (int j=0;j<=1e8;j++); }*/
  103.  
  104.     system("cls");
  105.  
  106.         ofstream myfile;
  107.         myfile.open("Transcript.txt");
  108.  
  109.     int Choice;
  110.  
  111.     cout<<"\n Examination Result"<<endl;
  112.     cout<<"\n\t1) Faculty of Computing"<<endl;
  113.  
  114.     cout<<"\n\tPlease enter the number of your faculty: ";
  115.         cin>>Choice;
  116.  
  117.         system("cls");
  118.  
  119.     cout<<"\n Examination Result"<<endl;
  120.  
  121.     switch (Choice){
  122.     case 1 :
  123.     cout<<"\n\tFaculty: Faculty of Computing"<<endl;
  124.     break; }
  125.  
  126.     if (Choice==1){
  127.  
  128.     cout<<"\n\tList of our courses:"<<endl;
  129.     cout<<"\t1) SCSR (Computer Network & Security)"<<endl;
  130.  
  131.         cout<<"\n\tPlease enter the number of your course: ";
  132.         cin>>Choice;
  133.         if (Choice !=1) {cout<<"\n\tChoice not valid. Please exit ! xD";
  134.         return 0;  }
  135.  
  136.         system("cls");
  137.  
  138.     myfile<<cout<<"\n Examination Result"<<endl;
  139.  
  140.     cout<<"\n Examination Result"<<endl;
  141.  
  142.     myfile<<"\n\tFaculty: Faculty of Computing"<<endl;
  143.     cout<<"\n\tFaculty: Faculty of Computing"<<endl;
  144.  
  145.     myfile<<"\tCourse : SCSR (Computer Network & Security)"<<endl;
  146.  
  147.         switch (Choice){
  148.     case 1 :
  149.     cout<<"\tCourse: SCSJ (Computer Network & Security)"<<endl;
  150.     break;
  151.     }  }
  152.  
  153.     else { cout<<"\n\tSorry ! We're currently working on this. xD"<<endl;
  154.     return 0;
  155.     };
  156.  
  157.     string* subject=new string[46];
  158.     string studentname;
  159.     string matricid;
  160.     bool bFail;
  161.  
  162.     cin.ignore();
  163.  
  164.     do {
  165.     cout<<"\n\tStudent Name: ";
  166.  
  167.     getline (cin,studentname);
  168.     bFail=cin.fail();
  169.         }  while (bFail==true);
  170.  
  171.     cout<<"\tMatric Number: ";
  172.     cin>>matricid;
  173.  
  174.     student st1(studentname, matricid);
  175.  
  176.     subject[0]="Discrete Structure                            ";
  177.     subject[1]="Programming Technique I                       ";
  178.     subject[2]="Technology & Information Systems              ";
  179.     subject[3]="Digital Logic                                 ";
  180.     subject[4]="Graduate Success Attributes                   ";
  181.     subject[5]="Malaysian Dynamic/ Malaysian Studies          ";
  182.  
  183.  
  184.     int credit[46];
  185.     float pointer[46];
  186.     float gpa[8];
  187.     float totalCredit;
  188.     float cgpa=0;
  189.     float sumTotalCredit;
  190.     float credpoint;
  191.     int sem, currentSub;
  192.     float x;
  193.     float sumCredPoint;
  194.     cout << "\tCurrent Semester (Now): ";
  195.     cin >> sem;
  196.  
  197.     int k=0;
  198.  
  199.     for(int i=0; i < sem ; i++)
  200.     {
  201.     cout << "\n\n\tNumber of Subjects: ";
  202.     cin >> currentSub;
  203.  
  204.     cout<<"\t============================================================"<<endl;
  205.                         cout<<"\t\t\t\t SEMESTER " << i+1 <<endl;
  206.     cout<<"\t============================================================"<<endl;
  207.     cout<<"\tLIST OF SUBJECTS :\t\t       CREDIT HRS:"<<"  POINTER:"<<endl;
  208.  
  209.     myfile<<"\n\t============================================================"<<endl;
  210.                         myfile<<"\t\t\t\t SEMESTER " << i+1 <<endl;
  211.     myfile<<"\t============================================================"<<endl;
  212.     myfile<<"\tLIST OF SUBJECTS :\t\t       CREDIT HRS:"<<"  POINTER:"<<endl;
  213.  
  214.         for(int j=0; j < currentSub; j++)
  215.         {
  216.             cout << "\t" << subject[k];
  217.             myfile << "\t" << subject[k];
  218.  
  219.             cin >> credit[k];
  220.             myfile << credit[k];
  221.                 cout<<"\t\t\t\t\t\t\t      ";
  222.  
  223.                 cin >> pointer[k];
  224.                 myfile <<"\t\t"<<pointer[k]<<endl;
  225.             totalCredit = totalCredit + credit[k];
  226.             st1.setTotalCredit(totalCredit);
  227.             x = (credit[k]*pointer[k]);
  228.             credpoint = credpoint + x;
  229.             k++;    
  230.         }
  231.         gpa[i] = st1.CalculateGpa(credpoint,totalCredit);
  232.         sumTotalCredit = sumTotalCredit+totalCredit;
  233.         sumCredPoint = sumCredPoint + credpoint;
  234.         cgpa = sumCredPoint/sumTotalCredit;
  235.         x=0;
  236.         credpoint = 0;
  237.         totalCredit=0;
  238.  
  239.     cout<<"\t============================================================"<<endl;
  240.     cout << "\t\t\t\t         GPA = "<< gpa[i]<<" /"<<" CGPA = "<< cgpa << endl;
  241.  
  242.     myfile<<"\t============================================================"<<endl;
  243.     myfile<< "\t\t\t\t         GPA = "<< gpa[i]<<" /"<<" CGPA = "<< cgpa << endl;   
  244.     }
  245.     cout<<"\n\tStudent Name: "<<st1.getName()<<endl;
  246.     cout<<"\tMatric Number: "<<st1.getId()<<endl;
  247.     cout<<"\tThe Final CGPA (Latest): "<< cgpa <<endl;
  248.  
  249.     myfile<<"\n\tStudent Name : "<<st1.getName()<<endl;
  250.     myfile<<"\tMatric Number: "<<st1.getId()<<endl;
  251.     myfile<<"\tThe Final CGPA (Latest): "<< cgpa <<endl;
  252.  
  253.     return 0; 
  254. }
  255.  
Feb 4 '21 #1
2 1826
dev7060
636 Expert 512MB
I need help how to add a subject code in this coding.
What is not working when trying to do such?
Feb 4 '21 #2
Banfa
9,065 Expert Mod 8TB
From line 57 string* subject=new string[46]; it appears that currently the code just treats the subject as a string, its name. Now you want to have both a name and a code for a subject that would suggest that you need a class to hold both the name and code and then change this allocation, and all the subsequent places in the code subject is used.

Finally on the subject of best practice this code would be far better if it used one of the standard containers, std::vector or std::list, to contain subjects rather than allocating a dynamic array not all of which is used; it would also be more scalable.
Feb 4 '21 #3

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

Similar topics

1
by: SallyBenjamin | last post by:
Hello.. Can anyone help me with this coding. Basically, it needs to have add node, remove node, add edges , remove edges and display the graph But.I have only succedded to add node, add and...
18
by: anand | last post by:
*********************************************************************************************************** #include<stdio.h> #include<conio.h> #include<math.h> void main() { double...
2
by: Tony Girgenti | last post by:
Hello. I'm trying to develop a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 comuter. I want to use a web form for this...
7
by: Brave | last post by:
I am hoping for a code example of how to do this, and hopefully it will help me to see an easy way to code what seems to be a huge monster. I need to create a form that has two pulldown menues...
6
kirubagari
by: kirubagari | last post by:
Private Sub check_click() Const a As Byte = 4 Const b As Byte = &HFF Dim i As Long Dim AnyChanged As Boolean Dim ChangeMade As Boolean For i = 49 To mFileSize Step 6 AnyChanged = False ...
10
by: sathynryn | last post by:
hi !....plz help me to run this coding..... create type browse as object(vs varchar 2(700)); create type visite as table of browse; create table inms(us varchar2(25), visdin visite) nested...
0
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and...
1
by: murthychvrm | last post by:
why we declare "ReportDocument doc;" in this coding?what it is doing here? using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using...
1
by: vgay3 | last post by:
i need B+ tree implementation coding in java. pls help me.
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.