Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,152,685 members, 7,816,794 topics. Date: Friday, 03 May 2024 at 05:18 PM |
Nairaland Forum / Science/Technology / Programming / Someone Should Help Me Solve This C++ Question Please (1564 Views)
Fix This C++ Code If You can / Help! Im Stuck With This C# Program / Please Programmars Help Me Out With This C# Program! I Have Test Tommorrow!!!!! (2) (3) (4)
Someone Should Help Me Solve This C++ Question Please by Mizblinks(f): 8:35am On Jun 09, 2016 |
I have test to write soon, I have been studying pretty well but I seems not be able to solve this question. Write a program in c++ to get the scores of 38 student in 300L The program should compile the 2 years of the score and print it. If you can solve the above question please help me do that. Thanking you in advance.. |
Re: Someone Should Help Me Solve This C++ Question Please by hardebayho(m): 9:04am On Jun 09, 2016 |
Not enough information |
Re: Someone Should Help Me Solve This C++ Question Please by olarid01: 3:15pm On Jun 09, 2016 |
Number of courses? of do you want it to be generalized? And what type of paradigm to use? POP or OOP? |
Re: Someone Should Help Me Solve This C++ Question Please by Mizblinks(f): 7:09pm On Jun 09, 2016 |
hardebayho:What information do you need please? |
Re: Someone Should Help Me Solve This C++ Question Please by Mizblinks(f): 7:13pm On Jun 09, 2016 |
olarid01: It's a sample question been asked by my lecturer, he didn't state if it is a POP or OOP, neither did he state the number of courses... |
Re: Someone Should Help Me Solve This C++ Question Please by hardebayho(m): 8:32pm On Jun 09, 2016 |
Mizblinks:Are you getting the scores from the keyboard or you're inputting it in the program? |
Re: Someone Should Help Me Solve This C++ Question Please by Mizblinks(f): 9:17pm On Jun 09, 2016 |
hardebayho: It's not that I want you to run the program, I want someone that can solve the question. e.g solving it this way. 1. # include <io stream> 2. using namespace std ; 3. main () 4. { 5. int scores ; 6. cout << "enter 38 scores" "/a" 7. for ( int, =0; < 38; ++ >; 8. (in >>, scores [ i ] 9. cin >> scores ( 300L > "endl" ; 10. cout << " the enter scores are //" < endl ; 11. return o; 12. } I know this is incorrect, but I want someone who can solve the question in this format. |
Re: Someone Should Help Me Solve This C++ Question Please by Vectormike(m): 12:52am On Jun 10, 2016 |
Very tough though. What school are you? |
Re: Someone Should Help Me Solve This C++ Question Please by hardebayho(m): 2:09am On Jun 10, 2016 |
Mizblinks: #include <iostream> using namespace std; int main() { int scores[38]; cout << "Enter 38 scores, and press enter after entering each score" << endl; for(int x = 0; x < 38; x++){ cin >> scores[x] ; cout << "The entered scores are: " << scores[x] << endl; } } Tell me if this does what you need. If it doesn't, then I still need more info |
Re: Someone Should Help Me Solve This C++ Question Please by olarid01: 1:10pm On Jun 10, 2016 |
hardebayho: Well done bro. But this won't take care of the two years and also it can be generalized so that the number of courses in each year will be requested at program start. Take a look a this: #include <stdafx.h> #include <iostream> using namespace std; int main() { char pause; //Number of courses per year int yone, ytwo; const int NoOfStudents = 2; cout << "\nHow Many Courses in Year One? " << "\t"; cin >> yone ; cout << "\nHow Many Courses in Year Two? " << "\t"; cin >> ytwo ; //Creating the student data structure struct Genstudent{ float *Yearone; float *Yeartwo; }; //Creating Array of students for the number of students Genstudent student[NoOfStudents]; //Initializing the students variables for(int x = 0; x < NoOfStudents; x++){ student[x].Yearone = new float[yone]; student[x].Yeartwo = new float[ytwo]; } //Getting All the Scores for(int x = 0; x < NoOfStudents; x++){ //getting the scores For Year One for all students cout<<"Student "<<x+1<<"\n"; cout<<"========="<<"\n"; for (int i=0; i<yone; i++){ cout<<"\n\tStudent"<<x+1<<": Input Score For Year 1 Course: "<<i+1<< "\t"; cin>>student[x].Yearone[i]; } //getting the scores For Year two for all students for (int i=0; i<ytwo; i++){ cout<<"\n\tStudent"<<x+1<<": Input Score For Year 2 Course: "<<i+1<< "\t"; cin>>student[x].Yeartwo[i]; } } //Printing All the Scores // For Year ONE cout << "\n\n\t\t The Scores For Year One Are\n"; cout << "\t\t === ====== === ==== === ===\n"; cout<<"\t\t"; for (int i=0; i<yone; i++){ cout<<"Course "<<i+1<<"\t"; } //putting a line break cout<<"\n"; for(int x = 0; x < NoOfStudents; x++){ //getting the scores For Year One for all students cout<<"Student"<<x+1<<": "<<" \t"; for (int i=0; i<yone; i++){ cout<<student[x].Yearone[i]<<"\t\t"; } cout<<"\n"; } // For Year TWO cout << "\n\n\t\t The Scores For Year Two Are\n"; cout << "\t\t === ====== === ==== === ===\n"; cout<<"\t\t"; for (int i=0; i<ytwo; i++){ cout<<"Course "<<i+1<<"\t"; } //putting a line break cout<<"\n"; for(int x = 0; x < NoOfStudents; x++){ //getting the scores For Year One for all students cout<<"Student"<<x+1<<": "<<" \t"; for (int i=0; i<ytwo; i++){ cout<<student[x].Yeartwo[i]<<"\t\t"; } cout<<"\n"; } //Deallocating All the used Array for(int x = 0; x < NoOfStudents; x++){ delete [] student[x].Yearone; delete [] student[x].Yeartwo; } cin>>pause; return 0; } |
Re: Someone Should Help Me Solve This C++ Question Please by olarid01: 1:13pm On Jun 10, 2016 |
olarid01: The value for the variable NoOfStudents can be changed to the number required (38) but mind you, inputting the number of courses as 5 for each year will generate a loop of 38*5....... so for testing sake, use small numbers |
Re: Someone Should Help Me Solve This C++ Question Please by olarid01: 1:17pm On Jun 10, 2016 |
olarid01: The variable NoOfStudents can be changed to the required number (38) but mind you inputting 5 as number of courses for year one and two will generated a input loop of 38*5*2 so, for testing sake, use small number |
Re: Someone Should Help Me Solve This C++ Question Please by hardebayho(m): 5:44pm On Jun 10, 2016 |
olarid01: For one bruh, I don't know c++. Two, the information she provided is not really clear to me. Nice code though. That should do it |
Re: Someone Should Help Me Solve This C++ Question Please by olarid01: 6:23pm On Jun 10, 2016 |
hardebayho: Thanks |
Re: Someone Should Help Me Solve This C++ Question Please by Mizblinks(f): 7:11pm On Jun 10, 2016 |
hardebayho: Thanks a bunch, I will digest this later... |
Re: Someone Should Help Me Solve This C++ Question Please by Mizblinks(f): 7:14pm On Jun 10, 2016 |
olarid01: This is just what I need. Jah bless you dear ...*hugs* |
Re: Someone Should Help Me Solve This C++ Question Please by hardebayho(m): 9:53pm On Jun 10, 2016 |
Mizblinks: You welcome |
(1) (Reply)
React Native Will Become The Best Solution For Mobile App Development / Nairalander Builds Smart Security Camera / Want To Automate Your Sme Data Sharing Contact Me
(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. 80 |