Ibromodzi's Posts
Nairaland Forum › Ibromodzi's Profile › Ibromodzi's Posts
1 2 3 4 5 6 7 8 9 10 11 (of 11 pages)
samueltoski:OK Thanks |
Sirnuel:I should go and learn OOP? so what do you call this? |
LordeCalifornia:Lol |
Ezechinwa:Thanks boss I would have love to do that but you won't believe that the code is written with an android compiler and also I do type with a mouse which makes it very tiring for me to implement separate file compilations. But I must shaa do something till I have a working PC. Thanks once again. |
It's my first code in OOP though plus I'm just a beginner. I would like to create a mobile app with this but don't have the necessary resources right now. Any idea on how to improve it is welcomed. |
//The program calculates the gpa/cgpa based on the commonest grading //system via 4.0,5.0 and 7.0. //The user is asked whether he is calculating for cgpa/gpa and also the //grade system #include <iostream> #include <vector> #include <cstdlib> using namespace std; class Cgpa//The base class that holds all the vectors and functions { protected: double gpa; double cgpa; int coursenumber; vector<double>courseunit;//for various course unit vector<double>gradeequivalent;//point equivalent to the grade vector<double>unitsum;//sums the total unit vector<double>gradevsunit;//multiplies grade and unit vector<double>sumgradevsunit;//sum of the grade and unit multiplied public: Cgpa(); Cgpa(double cnumber): coursenumber(cnumber),courseunit(cnumber),gradeequivalent(cnumber), unitsum(cnumber),gradevsunit(cnumber),sumgradevsunit(cnumber){} void getunit(); void getgrade(); double dounitsum(); void multiplygradeunit(); double dosumgradevsunit(); double dogpa(int Tpoint,int Tunit); double docgpa(int T,int P); void grading(int Tp,int Tu); void gradecgpa(int U,int G); void gradeinfo();//displays the point equivalent to the user }; class Fourpoint: public Cgpa//derived class for 4.0 grading system { public: Fourpoint(int cnumber):Cgpa(cnumber){} void gradeinfo4(); void grading4(int a,int b); void grading4b(int a,int b); private: double gpa4; double cgpa4; }; class Sevenpoint: public Cgpa//derived class for 7.0 grading system { public: Sevenpoint(int cnumber):Cgpa(cnumber){} void gradeinfo7(); void grading7(int a,int b); void grading7b(int c,int d); private: double gpa7; double cgpa7; }; //class Implementations void Cgpa::getunit() { for(int i = 0;i<coursenumber; i++) { cout<<"Input the unit for course "<<i+1<<": "; cin>>courseunit[i]; } } void Cgpa::gradeinfo() { cout<<"Enter the point equivalent to the grade scored i.e A is 5 B 4, C 3, D 2, E 1, F 1\n"; } void Cgpa::getgrade() { for(int i = 0; i<coursenumber; i++) { cout<<"Input the gradeequivalent for course "<<i+1<<": "; cin>>gradeequivalent[i]; } } double Cgpa::dounitsum() { int sumunit = 0; for(int i = 0; i<coursenumber; i++) { sumunit = sumunit + courseunit[i]; } return sumunit; } void Cgpa::multiplygradeunit() { for(int i = 0; i<coursenumber; i++) { gradevsunit[i] = courseunit[i] * gradeequivalent[i]; } } double Cgpa::dosumgradevsunit() { int sumgradeAndUnit = 0; for(int i = 0; i<coursenumber; i++) { sumgradeAndUnit = sumgradeAndUnit + gradevsunit[i]; } return sumgradeAndUnit; } double Cgpa::dogpa(int Tpoint,int Tunit) { return Tpoint/static_cast<double>(Tunit); } double Cgpa::docgpa(int T,int P) { return T/static_cast<double>(P); } void Cgpa::grading(int Tp,int Tu) { gpa = dogpa(Tp,Tu); if(gpa >= 4.5) { cout<<"\nYour GPA is "<<gpa<<" which corresponds to the FIRST CLASS division\n What an exellent performance! Keep it up."<<endl; } else if(gpa >= 3.5 && gpa < 4.50) { cout<<"\nYour GPA is "<<gpa<<" which corresponds to the SECOND CLASS UPPER division\n That's a good performance, just some points away from first class. Strive harder next time"<<endl; } else if(gpa >= 2.5 && gpa < 3.5) { cout<<"\nYour GPA is "<<gpa<<" which corresponds to the SECOND CLASS LOWER division\n You can still do better, just some points away from second class upper. Strive harder next time"<<endl; } else if(gpa >= 1.5 && gpa < 2.5) { cout<<"\nYour GPA is "<<gpa<<" which corresponds to the THIRD CLASS division\n You are born to be great. Double your hustle to be in the class you belong to. You can always do better\n"; } else { cout<<"\nYour GPA is"<<gpa<<" which corresponds to the PASS category\n Being in this category does not imply that you are so poor academically, it only gives you a challenge of life which you must face. Sit yourself down and think of the best way(s) possible to sort things out, if possible, try to talk to the experienced ones or probably meet a coucellor\n Wish you best of luck!"<<endl; } } void Cgpa::gradecgpa(int U,int G) { cgpa = docgpa(U,G); if(cgpa >= 4.5) { cout<<"\nYour CGPA is "<<cgpa<<" which corresponds to the FIRST CLASS division \n What an exellent performance! Keep it up. "<<endl; } else if(cgpa >= 3.5 && cgpa < 4.50) { cout<<"\nYour CGPA is "<<cgpa<<" which corresponds to the SECOND CLASS UPPER division\n That's a good performance, just some points away from first class. Strive harder next time "<<endl; } else if(cgpa >= 2.5 && cgpa < 3.5) { cout<<"\nYour CGPA is "<<cgpa<<" which corresponds to the SECOND CLASS LOWER division\n You can still do better, just some points away from second class upper. Strive harder next time "<<endl; } else if(cgpa >= 1.5 && cgpa < 2.5) { cout<<"\nYour CGPA is "<<cgpa<<" which corresponds to the THIRD CLASS division\n You are born to be great. Double your hustle to be in the class you belong to. You can always do better \n"; } else { cout<<"\nYour CGPA is"<<cgpa<<" which corresponds to the PASS category\n Being in this category does not imply that you are so poor academically, it only gives you a challenge of life which you must face. Sit yourself down and think of the best way(s) possible to sort things out, if possible, try to talk to the experienced ones or probably meet a coucellor\n Wish you best of luck! "<<endl; } } void Fourpoint::gradeinfo4() { cout<<"Enter the point equivalent to the grade scored i.e A is 4.0,AB 3.5,B 3.0, etc.\n"; } void Fourpoint::grading4(int a,int b) { gpa4 = dogpa(a,b); if(gpa4>=3.5) { cout<<"Your GPA is "<<gpa4<<"which corresponds to DISTINCTION\n What an exellent performance! Keep it up. "; } else if(gpa4 >= 3.0 && gpa4 <= 3.49) { cout<<"Your GPA is "<<gpa4<<" which corresponds to the UPPER CREDIT division\n That's a good performance, just some points away from distinction. Strive harder next time\n"; } else if(gpa4 >= 2.5 && gpa4 <= 2.99) { cout<<"Your GPA is "<<gpa4<<" which corresponds to the LOWER CREDIT division\n You can still do better, just some points away from upper credit. Strive harder next time\n"; } else if(gpa4 >= 2.00 && gpa4 <= 2.49) { cout<<"Your GPA is "<<gpa4<<" which corresponds to PASS\n You are born to be great. Double your hustle to be in the class you belong to. You can always do better \n"; } else { cout<<"Your GPA is "<<gpa4<<" which corresponds to FAIL\n Being in this category does not imply that you are so poor academically, it only gives you a challenge of life which you must face. Sit yourself down and think of the best way(s) possible to sort things out, if possible, try to talk to the experienced ones or probably meet a coucellor\n Wish you best of luck! \n"; } } void Fourpoint::grading4b(int a,int b) { cgpa4 = dogpa(a,b); if(cgpa4>=3.5) { cout<<"Your CGPA is "<<cgpa4<<"which corresponds to DISTINCTION\n What an exellent performance! Keep it up. "; } else if(cgpa4 >= 3.0 && cgpa4 <= 3.49) { cout<<"Your CGPA is "<<cgpa4<<" which corresponds to the UPPER CREDIT division\n That's a good performance, just some points away from distiction. Strive harder next time\n"; } else if(cgpa4 >= 2.5 && cgpa4 <= 2.99) { cout<<"Your CGPA is "<<cgpa4<<" which corresponds to the LOWER CREDIT division\n You can still do better, just some points away from upper credit. Strive harder next time \n"; } else if(cgpa4 >= 2.00 && cgpa4 <= 2.49) { cout<<"Your CGPA is "<<cgpa4<<" which corresponds to PASS\n You are born to be great. Double your hustle to be in the class you belong to. You can always do better \n"; } else { cout<<"Your CGPA is "<<cgpa4<<" which corresponds to FAIL\n Being in this category does not imply that you are so poor academically, it only gives you a challenge of life which you must face. Sit yourself down and think of the best way(s) possible to sort things out, if possible, try to talk to the experienced ones or probably meet a coucellor\n Wish you best of luck! \n"; } } void Sevenpoint::gradeinfo7() { cout<<"Enter the point equivalent to the grade scored i.e A is 7.0,B 3.5,B 6.0,C 5,D 4/3, E 2/1 F 0 \n"; } void Sevenpoint::grading7(int a, int b) { gpa7 = dogpa(a,b); if(gpa7 >= 6) { cout<<"\nYour GPA is "<<gpa7<<" which corresponds to the FIRST CLASS division\n What an exellent performance! Keep it up. "<<endl; } else if(gpa7 >= 4.6 && gpa7 <= 5.99) { cout<<"\nYour GPA is "<<gpa7<<" which corresponds to the SECOND CLASS UPPER division\n That's a good performance, just some points away from first class. Strive harder next time"<<endl; } else if(gpa7 >= 2.6 && gpa7 <= 4.59) { cout<<"\nYour GPA is "<<gpa7<<" which corresponds to the SECOND CLASS LOWER division\n You can still do better, just some points away from second class upper. Strive harder next time "<<endl; } else if(gpa7 >= 1.6 && gpa7 <= 2.59) { cout<<"\nYour GPA is "<<gpa7<<" which corresponds to the THIRD CLASS division\n You are born to be great. Double your hustle to be in the class you belong to. You can always do better \n"; } else { cout<<"\nYour GPA is"<<gpa7<<" which corresponds to the PASS category\n Being in this category does not imply that you are so poor academically, it only gives you a challenge of life which you must face. Sit yourself down and think of the best way(s) possible to sort things out, if possible, try to talk to the experienced ones or probably meet a coucellor\n Wish you best of luck! "<<endl; } } void Sevenpoint::grading7b(int c,int d) { cgpa7 = dogpa(c,d); if(cgpa7 >= 6) { cout<<"\nYour CGPA is "<<cgpa7<<" which corresponds to the FIRST CLASS division\n What an exellent performance! Keep it up. "<<endl; } else if(cgpa7 >= 4.6 && cgpa7 <= 5.99) { cout<<"\nYour CGPA is "<<cgpa7<<" which corresponds to the SECOND CLASS UPPER division\n That's a good performance, just some points away from first class. Strive harder next time" <<endl; } else if(cgpa7 >= 2.6 && cgpa7 <= 4.59) { cout<<"\nYour CGPA is "<<cgpa7<<" which corresponds to the SECOND CLASS LOWER division\n You can still do better, just some points away from second class upper. Strive harder next time "<<endl; } else if(cgpa7 >= 1.6 && cgpa7 <= 2.59) { cout<<"\nYour CGPA is "<<cgpa7<<" which corresponds to the THIRD CLASS division\n You are born to be great. Double your hustle to be in the class you belong to. You can always do better \n"; } else { cout<<"\nYour CGPA is"<<cgpa7<<" which corresponds to the PASS category\n Being in this category does not imply that you are so poor academically, it only gives you a challenge of life which you must face. Sit yourself down and think of the best way(s) possible to sort things out, if possible, try to talk to the experienced ones or probably meet a coucellor\n Wish you best of luck! "<<endl; } } //Application int main() { cout.setf(ios::fixed); //setting the cout.setf(ios::showpoint); //points to come cout.precision(2); //after decimal int n,a;//represents the call to constructor n double Totalunit,Gradevsunit; char ans; double grade; cout<<" ********************************************\n"; cout<<" ~~~~~~~~~~~~~~~~~CGPA CALCULATOR~~~~~~~~~~~~~~~~~~~~~~~~\n"; cout<<"Designed to calculate your gpa/cgpa effectively\n"; cout<<"Wish you good luck as you calculate\n"; cout<<"Are you calculating your GPA or CGPA? GPA is just a semester result while CGPA is a sessional result. Input a for GPA or b for CGPA\n"; cin>>ans; cout<<"What's your school's grading system 4.0,5.0 or 7.0\n"; cin>>grade; if(ans=='a' && grade == 5.0) { cout<<"Enter the total number of courses offered for the semester\n"; cin>>n; Cgpa semester(n); semester.getunit(); semester.gradeinfo(); semester.getgrade(); Totalunit = semester.dounitsum(); semester.multiplygradeunit(); Gradevsunit = semester.dosumgradevsunit(); semester.dogpa(Gradevsunit,Totalunit); semester.grading(Gradevsunit,Totalunit); } else if(ans == 'b' && grade == 5.0) { cout<<" INPUT FOR FIRST SEMESTER\n"; cout<<"Enter the total number of courses offered in first semester\n"; cin>>n; Cgpa semester1(n); semester1.getunit(); semester1.gradeinfo(); semester1.getgrade(); double Totalunit1 = semester1.dounitsum(); semester1.multiplygradeunit(); double Gradevsunit1 = semester1.dosumgradevsunit(); double gpa = semester1.dogpa(Gradevsunit1,Totalunit1); cout<<"\nYour gpa for first semester is "<<gpa<<endl; cout<<" INPUT FOR SECOND SEMESTER\n"; cout<< "Enter the total number of courses offered in second semester\n"; cin>>a; Cgpa sessional(a); sessional.getunit(); sessional.getgrade(); double Totalunit2 = sessional.dounitsum(); sessional.multiplygradeunit(); double Gradevsunit2 = sessional.dosumgradevsunit(); double gpa2 = sessional.dogpa(Gradevsunit2,Totalunit2); cout<<"\nYour gpa for second semester is "<<gpa2<<endl; double Unit = Totalunit1 + Totalunit2; double Grade = Gradevsunit1 + Gradevsunit2; double cgpa = sessional.docgpa(Unit,Grade); sessional.gradecgpa(Grade,Unit); } else if(ans =='a' && grade == 4.0) { int b; cout<<"Enter the total number of courses offered for the semester\n"; cin>>b; Fourpoint gpa4(b); gpa4.getunit(); gpa4.gradeinfo4(); gpa4.getgrade(); Totalunit = gpa4.dounitsum(); gpa4.multiplygradeunit(); Gradevsunit = gpa4.dosumgradevsunit(); gpa4.dogpa(Gradevsunit,Totalunit); gpa4.grading4(Gradevsunit,Totalunit); } else if(ans=='b' && grade == 4.0) { cout<<" INPUT FOR FIRST SEMESTER\n"; cout<<"Enter the total number of courses offered in first semester\n"; cin>>n; Fourpoint gpa41(n); gpa41.getunit(); gpa41.gradeinfo4(); gpa41.getgrade(); double Totalunit41 = gpa41.dounitsum(); gpa41.multiplygradeunit(); double Gradevsunit41 = gpa41.dosumgradevsunit(); double gpa41a = gpa41.dogpa(Gradevsunit41,Totalunit41); cout<<"\nYour GPA for first semester is "<<gpa41a<<endl; cout<<" INPUT FOR SECOND SEMESTER\n"; cout<< "Enter the total number of courses offered in second semester\n"; cin>>n; Fourpoint gpa42(n); gpa42.getunit(); gpa42.gradeinfo4(); gpa42.getgrade(); double Totalunit42 = gpa42.dounitsum(); gpa42.multiplygradeunit(); double Gradevsunit42 = gpa42.dosumgradevsunit(); double gpa42a = gpa42.dogpa(Gradevsunit42,Totalunit42); cout<<"\nYour GPA for second semester is "<<gpa42a<<endl; double Unit4 = Totalunit41 + Totalunit42; double Grade4 = Gradevsunit41 + Gradevsunit42; gpa42.grading4b(Grade4,Unit4); } else if(ans=='a' && grade==7.0) { cout<<"Enter the total number of courses offered for the semester\n"; cin>>n; Sevenpoint gpa7(n); gpa7.getunit(); gpa7.gradeinfo7(); gpa7.getgrade(); Totalunit = gpa7.dounitsum(); gpa7.multiplygradeunit(); Gradevsunit = gpa7.dosumgradevsunit(); gpa7.dogpa(Gradevsunit,Totalunit); gpa7.grading7(Gradevsunit,Totalunit); } else if(ans =='b' && grade ==7.0) { cout<<" INPUT FOR FIRST SEMESTER\n"; cout<<"Enter the total number of courses offered in first semester\n"; cin>>n; Sevenpoint gpa71(n); gpa71.getunit(); gpa71.gradeinfo7(); gpa71.getgrade(); double Totalunit71 = gpa71.dounitsum(); gpa71.multiplygradeunit(); double Gradevsunit71 = gpa71.dosumgradevsunit(); double gpa71a = gpa71.dogpa(Gradevsunit71,Totalunit71); cout<<"\nYour GPA for first semester is "<<gpa71a<<endl; cout<<" INPUT FOR SECOND SEMESTER\n"; cout<< "Enter the total number of courses offered in second semester\n"; cin>>n; Sevenpoint gpa72(n); gpa72.getunit(); gpa72.gradeinfo7(); gpa72.getgrade(); double Totalunit72 = gpa72.dounitsum(); gpa72.multiplygradeunit(); double Gradevsunit72 = gpa72.dosumgradevsunit(); double gpa72a = gpa72.dogpa(Gradevsunit72,Totalunit72); cout<<"\nYour GPA for second semester is "<<gpa72a<<endl; double Unit7 = Totalunit71 + Totalunit72; double Grade7 = Gradevsunit71 + Gradevsunit72; gpa72.grading7b(Grade7,Unit7); } else { cout<<"\nEither the grading system or input for cgpa/gpa is wrong. Rerun the program"; exit(1); } } |
Darey00:That's nice I'm also a c++ beginner and that's my latest code |
TobiTobiTobiWhy:Nice one... I've been busy since, I would have given it a trial too. Could you please chat me up on WhatsApp @08164402922. |
excanny:Try code block |
TobiTobiTobiWhy:Thanks.. |
excanny:I'm using cppdroid.... |
//The program does simple calculations like add and sub #include <iostream> #include <cstdlib> using std::cout; using std::cin; int dosum(int a,int b); int dosub(int a,int b); int main() { char ans; int a,b; cout<<"What type of operation do wish to perform? enter a for additions or s for subtraction\n"; cin>>ans; if(ans!='a'&& ans!='s') { cout<<"You entered the wrong answer for the opration to be performed\n"; exit(1); /*the program exits if the user enters a wrong specification for operation*/ } cout<<"Input the two numbers\n"; cin>>a, cin>>b; if (ans=='a'||ans=='A') { cout<<"The sum of the two numbers entered is "<<dosum(a,b)<<" \n"; } else if(ans=='s'||ans=='S') { cout<<"The difference of the two numbers is "<<dosub(a,b)<<" \n"; } return 0; } int dosum(int a,int b) { return a+b; } int dosub(int a,int b) { return a-b; } |
TobiTobiTobiWhy:I'm having problem using that online compiler but here is my code |
Project of the day The government research lab has concluded that an artificial sweetener commonly used in diet will cause death in laboratory mice. A friend of yours is desperate to lose weight but can't give up soda. Your friend wants to know how much diet soda it is possible to drink without dying as a result. Write a program to supply the answer. The input to the program is the amount of artificial sweetener needed to kill a mouse,the weight of the mouse and the weight of the dieter. To ensure the safety of your friend, be sure the program requests the weight at which he will stop dieting rather than the dieter's current weight. Assuming that diet soda contains one-tenth of 1% artificial sweetener. Use a variable declaration with modifier const to give a name to this fraction. You may want to express the percentage as double value 0.001. Extracted from Savitch Absolute C++, first edition. |
Hello everyone! Practice they say makes perfect and to any coder who wish to be a very sound programmer, practice is something that is very important. So in the light of this, I have come up with this idea that programming projects should be uploaded at least once in a week and solutions will be provided by any coder who takes his/her time to solve them. What is delimitatiing some beginners I think is the non availability of enough projects/exercises to work on and as a matter of fact doing something over and over again is the only way to learn to do it well. Therefore, I think this would be of help to baby programmers as well as intermediates and experts. However, the only issue is that I only code in C++ therefore I can only upload C++ projects. Thanks. I'll be uploading the project for today subsequently. |
may He find them on time |
may God help d NA |
only in nija |
mansha Allah, jazakumullah khaira |
RIP |
ionsman: steppin:I am not surprised to hear this because u were nt among those that experienced it.....the fact that u r ready to pay any amount will be a story when there is no cab to convey u to ur destination. Am very sure that those pple insyd all have their T-fare with them.....the question is dt would they even dare to trek out of d skul? definitely no |
Guy u sud just be thankful because u HV realized DT wht u r doing is bad and its even disrupting ur career,u just have to make up ur mind and 4get about any girl 4 nw.....after all u HV had sex for more than 1460 times according to u, so there sud be nothing exciting in it again. |
"