Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,619 members, 7,809,274 topics. Date: Friday, 26 April 2024 at 07:09 AM |
Nairaland Forum / Science/Technology / Programming / I Need An Ingenious Way Of Doing This. (1007 Views)
Better Way Of Writing This Java Code / X Years Of Programming - X Years Of Doing Things Wrong / Can Somebody Tell Me The Object-oriented Way Of Becoming Wealthy? (2) (3) (4)
I Need An Ingenious Way Of Doing This. by Hawlahscho(m): 12:31am On Oct 14, 2014 |
This is a GP calculator but I want it to be able to calculate as many courses as he or she can, for example, if user enters -1 it shud show that he or she is tru with d courses. if (grade==-1) {goto........} someone shud pls respond. I think programmers shud understand. Thanks in advance. #include <iostream> #include<math.h> using namespace std; int main() { //THIS SHOWS THAT THE FOLLOWING ARE CHARACTER VARIABLE char surname [12]; char firstname [12]; char othername [20]; char matricno[12]; char sex[6]; char dept[20]; char faculty[20]; char level[12]; //THIS SHOWS THE FOLLOWING ARE NUMERIC VARIABLE WITH DATA TYPE OF FLOATING POINT float grade1,grade2,grade3,grade4,grade5,grade6,grade7,grade8,grade9,grade10,grade11,grade12,grade13,grade14,grade15,grade16,grade17,grade18,grade19,grade20; float unit1,unit2,unit3,unit4,unit5,unit6,unit7,unit8,unit9,unit10,unit11,unit12,unit13,unit14,unit15,unit16,unit17,unit18,unit19,unit20; float point1,point2,point3,point4,point5,point6,point7,point8,point9,point10,point11,point12,point13,point14,point15,point16,point17,point18,point19,point20; float totalu,totalp,GPA; // COLLECTION OF DATA FROM USER. cout<<"CLI GP CALCULATOR BY OLA"<<endl<<endl; cout<<"TYPE YOUR NAME & PRESS ENTER: \v"; cin>>firstname; cout<<""<<endl<<endl; cout<<"Dear "<<firstname<<","<<"\t"<<"\a"<<"Press enter as soon as you finish with a particular line.\n"<<endl; cout<<"Follow the instructions below for your input\n"<<endl; cout<<"Input 5 as grade if your grade is A\n"; cout<<"Input 4 as grade if your grade is B\n"; cout<<"Input 3 as grade if your grade is C\n"; cout<<"Input 2 as grade if your grade is D\n"; cout<<"Input 1 as grade if your grade is E\n"; cout<<"Input 0 as grade if your grade is F\n"<<endl; if (grade2==1) goto next; cout<<"INPUT YOUR 1ST COURSE GRADE: ⇨ "; cin>>grade1; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit1; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade2; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit2; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade3; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit3; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade4; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit4; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade5; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit5; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade6; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit6; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade7; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit7; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade8; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit8; cout<<""<<endl; cout<<"INPUT THE NEXT COURSE GRADE: ⇨ "; cin>>grade9; cout<<"INPUT THE UNIT FOR THE COURSE: ⇨ "; cin>>unit9; cout<<""<<endl; //VARIABLES DEFINITION point1=grade1*unit1; point2=grade2*unit2; point3=grade3*unit3; point4=grade4*unit4; point5=grade5*unit5; point6=grade6*unit6; point7=grade7*unit7; point8=grade8*unit8; point9=grade9*unit9; point10=grade10*unit10; point11=grade11*unit11; point12=grade12*unit12; point13=grade13*unit13; point14=grade14*unit14; point15=grade15*unit15; point16=grade16*unit16; point17=grade17*unit17; point18=grade18*unit18; point19=grade19*unit19; point20=grade20*unit20; totalu=unit1+unit2+unit3+unit4+unit5+unit6+unit7+unit8+unit9+unit10+unit11+unit12+unit13+unit14+unit15+unit16+unit17+unit18+unit19+unit20; totalp=point1+point2+point3+point4+point5+point6+point7+point8+point9+point10+point11+point12+point13+point14+point15+point16+point17+point18+point19+point20; GPA=totalp/totalu; { //THE FINAL OUTPUT THAT WILL SHOW ON SCREEN next: cout<<"Your Grade Point Average for the semester is: ⇨ " <<GPA<<"\n"; if(GPA<= 1.49) cout<<"Dear "<<firstname<<"\t"<<"You didn't do well at all, try very hard next semester.\n"; else if(GPA<= 2.49) cout<<"Dear "<<firstname<<"\t"<<"You passed, but you really need improvement.\n"; else if(GPA<= 3.49) cout <<"Dear " <<firstname<<"\t"<<"You have lower credit, you can do better next semester.\n"; else if(GPA<= 4.49) cout<<"Dear " <<firstname<<"\t"<<"Encouraging!!! you made it to upper credit, more grease to your elbow.\n"; else if(GPA<= 5.00) cout<<"Wow!!! Congratulations!!! \t"<<firstname<<"\t"<<"You have distinction, you're a first class student, make it constant. \a"; else cout<<"wrong input!!!\n"; return 0; } } |
Re: I Need An Ingenious Way Of Doing This. by codemarshal08(m): 5:32am On Oct 14, 2014 |
Use a Loop Statement and Check Your Input against the value -1 |
Re: I Need An Ingenious Way Of Doing This. by Hawlahscho(m): 7:53am On Oct 14, 2014 |
codemarshal08: I forgot to show d programme b4, check it now. |
Re: I Need An Ingenious Way Of Doing This. by codemarshal08(m): 6:05pm On Oct 14, 2014 |
Your Code Look too Busy bro. *Use Vectors and loops to Read in Multiple Courses, units and Grades *i will Advice you to check Your Course input against a letter like "x" or "X", why ?, Because You cant compare a string with an Int. expect You want to go tru conversion process. |
Re: I Need An Ingenious Way Of Doing This. by zeroshadow: 9:18am On Oct 15, 2014 |
Hawlahscho: send me a mail.... I'll do it for a fee... |
Re: I Need An Ingenious Way Of Doing This. by Hawlahscho(m): 10:27am On Oct 15, 2014 |
zeroshadow: Thanks boss. I just did it. Actually it's an assignment, I had to think better and I created a do loop with internal if command. That did d magic. #RESPECT TO ELDERS |
Re: I Need An Ingenious Way Of Doing This. by codemarshal08(m): 10:54am On Oct 15, 2014 |
Hawlahscho: I am happy You Got the Idea at Last......... Happy Coding ! 1 Like |
(1) (Reply)
Easy CBT / Nigeria Kid Coders / Javascript
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38 |