Question:
Need lots of help. code not working anymore, how do I get my C++ code working again?
Jason
2012-06-25 17:05:23 UTC
READ ALL OF THE DETAILS
Ok, I need to figure out how to make and use the functors(function objects) , make and use a sort function for each data entry held in a record, (8 different pieces of data), and also get my code working again. Here are the specific requirements(again):

Given a file containing student information records in the following format (one record a line):
Last_name, first_name initial; class; major; minor; total credit hours; GPA; academic standing
For example:
Williams, John D.; Junior; IT; Math; 118; 3.29; Good
Doe, Jane K.; Freshman; Sociology; None; 75; 2.8; Average
…..
Requirements:
1. Design and implement a class to represent the student record with function objects for comparing last name, first name, total credit hours, and GPA.
2. Implement a menu-based application that with the following features:
Main menu:
i. Show Records
ii. Sort Records
iii. Exit
Your program will load all the records from a file, named “student.records”, into a vector when it is launched, and then show the main menu.
Show Records: when selected will show the first five records, and allows user to choose either “next five”, “previous five” or “Main Menu” and react to the user’s input accordingly.
Sort Records: allows the user to choose one of the following fields to sort: last name, first name, total credit hours, and GPA. Your program will sort the vector of record based on the user’s selected option and proceed to “Show record”, i.e. show 5 records at a time. – You can consult the template bubble sort function in chapter 3.
Exit: terminate the program

My current code is missing the sort function and I think the function objects(don't know if I have them without realizing it). I had the output working properly, but had to make changes because it was outputting the same thing no matter what input, and was always repeating the main menu output prompt. However, now when it runs, it doesn't do anything, it just has a cursor in cmd prompt. So here is my code now, please tell me exactly what I need to do to get it working without any problems, and what I need to do to meet the requirements: http://pastebin.com/YtgXKb6c Remember comments and explanations, and specifics.
Three answers:
?
2012-06-25 17:16:36 UTC
You added a semicolon after your while conditional... more details... !=1 !=2 !=3



also on your if conditionals below it you should be using ==



furthermore... if you try to exit out of a choice it will return to the function and skip the input... Jeff had this perfectly fine the other day using a single while loop and switch case...



while ((mainMenuChoice != 3))

{

cout<<"\nInput a number corresponding to your menu choice and press enter. Will repeat if invalid entry entered."<
cout<<"1. Show records"<
cout<<"2. Sort Records"<
cout<<"3. Exit"<
cin>>mainMenuChoice;



switch(mainMenuChoice){

case 1:

showRecords(studentRecordVector);

break;

case 2:

sortRecords(studentRecordVector);

break;

case 3:

return 0;

default:

cout<< "Error" <
}



}
anonymous
2016-12-11 15:56:48 UTC
Kaiji - Its a pair of guy who makes use of clever hints to get out of debt from gangsters. corresponding to a minimum of one Outs. Spice and Wolf - the tale is a pair of provider provider who meets a wolf goddess who's attempting to come back to her fatherland. jointly, the two use their adventure and information alongside the way. corresponding to C, in that they the two deal approximately economics. in spite of the shown fact that, Spice and Wolf is going lots extra in economics. Legend of the Galactic Heroes - think of Code Geass without "magical eyes", mechs, suggestions like "the only that yells louder wins", immortal women persons and stupid idealism (hi Suzaku). You with me so some distance? Now, think of Code Geass the place there are dozens of super commanders like Lelouch on the two factors, the place political intrigues, plots and schemes are some distance from uncommon. think of battles of epic proportions and conflict on the galactic scale, the place winning ingredient is desperate in undemanding terms via commanders intelligence, sort of troops, their morale and accessible components, no longer superunits like Lancelot. try this and you have invented LoGH. BTW: theory of significant hero searching for vengeance against Empire that did undesirable issues to his sister, and exacting this vengeance utilising militia and political means first regarded in LoGH, no longer CG. Lelouch copied Reinhard in many techniques, yet i will't say it rather is a nasty element. LoGH is in basic terms too damn good to no longer be copied.
Hippiezoo
2012-06-25 17:10:25 UTC
Can't help u with out looking at the code


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...