Posted May 15, 200717 yr Well, i took C++ for no reason and it is now too late to drop it. ~_~ So this is the final and i have no idea where to start. Final Write a program that grades the multiple choice drivers' license exam. The exam has the following answer key. 1. B 2. D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D 11. B 12. C 13. D 14. A 15. D 16. C 17. C 18. B 19. D 20. A The program will input a person's answers and uses the following method to display the percent correct. 1. passed is a Boolean that returns true if they answer at least 15 out of 20 correctly. 2. totalCorrect is an integer method that returns the number of correct answers. 3. Program contains at least 3 functions and 1 array. 4. Program must use an input file for data and 1 loop to read data. So anyone know where to start or at least know the source or just write the source code for this program for me? ~_~ Big karma to you. Must be turned in by 4pm tomorrow. ~_~ PST time.
May 15, 200717 yr #include <iostream.h> int One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Forteen, Fifteen, Eighteen, Nineteen, Twenty, passed; int main() { cout << "\nWhat is the answer to question 1?\nAnswer A,B,C,D"; cout << "\nStatement" cin >> One; if (One==65 || One==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 2? "; if (Two==65 || Two==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 3? "; if (Three==65 || Three==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 4? "; if (Four==65 || Four==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 5? "; if (Five==65 || Five==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 6? "; if (Six==65 || Six==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 7? "; if (Seven==65 || Seven==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 8? "; if (Eight==65 || Eight==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 9? "; if (Nine==65 || Nine==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 10? "; if (Ten==65 || Ten==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 11? "; if (Eleven==65 || Eleven==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 12? "; if (Twelve==65 || Twelve==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 13? "; if (Thirteen==65 || Thirteen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 14? "; if (Forteen==65 || Forteen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 15? "; if (Fifteen==65 || Fifteen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 16? "; if (Sixteen==65 || Sixteen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 17? "; if (Seventeen==65 || Seventeen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 18? "; if (Eighteen==65 || Eighteen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 19? "; if (Nineteen==65 || Nineteen==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 20? "; if (Twenty==65 || Twenty==97) \\ If answer is A then statement will follow cout << "Congratulations right answer" << endl; passed++; else \\ If answer not A statement follows cout << "Sorry, wrong answer"; if (passed > 15) cout << "\nWell done you have passed\nPress any key to exit"; cin >> One; else cout << "\nSorry, you have failed\nPress any key to exit"; cin >> One; } Totally untested, did it in notepad about 20 minutes. As you can see my c++ sucks.
May 15, 200717 yr I hope you fail the class. That is so incredibly easy if you payed any attention at all.
May 15, 200717 yr #include <iostream> using namespace std; int One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Forteen, Fifteen, Sixteen, Seventeen, Eighteen, Nineteen, Twenty, passed; int main() { cout << "\nWhat is the answer to question 1?\nAnswer A,B,C,D"; cin >> One; if (One==65 || One==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 2? "; if (Two==65 || Two==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 3? "; if (Three==65 || Three==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 4? "; if (Four==65 || Four==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 5? "; if (Five==65 || Five==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 6? "; if (Six==65 || Six==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 7? "; if (Seven==65 || Seven==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 8? "; if (Eight==65 || Eight==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 9? "; if (Nine==65 || Nine==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 10? "; if (Ten==65 || Ten==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 11? "; if (Eleven==65 || Eleven==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 12? "; if (Twelve==65 || Twelve==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 13? "; if (Thirteen==65 || Thirteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 14? "; if (Forteen==65 || Forteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 15? "; if (Fifteen==65 || Fifteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 16? "; if (Sixteen==65 || Sixteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 17? "; if (Seventeen==65 || Seventeen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 18? "; if (Eighteen==65 || Eighteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 19? "; if (Nineteen==65 || Nineteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 20? "; if (Twenty==65 || Twenty==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; if (passed > 15) { cout << "\nWell done you have passed\nPress any key to exit"; cin >> One; } else cout << "\nSorry, you have failed\nPress any key to exit"; cin >> One; } ok loadsa errors fixed but wont run now? :s
May 15, 200717 yr backwards;474604']I hope you fail the class. That is so incredibly easy if you payed any attention at all. qft
May 16, 200717 yr I was bored and it was easy. This is pretty much guaranteed to work. I recommend that you let this program run for at least 5-10 minutes to grind out the most accurate results. Your teacher will be impressed. ~__~ back at ya #include <stdio.h> #include <unistd.h> #define FILENAME "grades.txt" int main() { int i; char gradeTable[20][1]; FILE* init; init = fopen(FILENAME, "r"); for(i = 0; i < 20; i++) { fscanf(init, "%i\n", gradeTable[i][0]); } grader(gradeTable); } void readIn(int answer, int i) { while(1) { fork(); readOut(answer, i); } } int readOut(int reply, int i) { int totalCorrect; char answer[20] = "BDAACABACDBCDADCCBD"; while(1) { if(reply == answer[i]) { totalCorrect++; } fork(); } return totalCorrect; } int grader(char** gradeTable) { int i; for(i = 0; i < 20; i++) { readIn(gradeTable[i][0], i); } }
May 16, 200717 yr #include <iostream> using namespace std; int One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Forteen, Fifteen, Sixteen, Seventeen, Eighteen, Nineteen, Twenty, passed; int main() { cout << "\nWhat is the answer to question 1?\nAnswer A,B,C,D"; cin >> One; if (One==65 || One==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 2? "; if (Two==65 || Two==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 3? "; if (Three==65 || Three==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 4? "; if (Four==65 || Four==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 5? "; if (Five==65 || Five==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 6? "; if (Six==65 || Six==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 7? "; if (Seven==65 || Seven==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 8? "; if (Eight==65 || Eight==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 9? "; if (Nine==65 || Nine==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 10? "; if (Ten==65 || Ten==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 11? "; if (Eleven==65 || Eleven==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 12? "; if (Twelve==65 || Twelve==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 13? "; if (Thirteen==65 || Thirteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 14? "; if (Forteen==65 || Forteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 15? "; if (Fifteen==65 || Fifteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 16? "; if (Sixteen==65 || Sixteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 17? "; if (Seventeen==65 || Seventeen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 18? "; if (Eighteen==65 || Eighteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 19? "; if (Nineteen==65 || Nineteen==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; cout << "\nWhat is the answer to question 20? "; if (Twenty==65 || Twenty==97) // If answer is A then statement will follow { cout << "Congratulations right answer" << endl; passed++ ; } else // If answer not A statement follows cout << "Sorry, wrong answer"; if (passed > 15) { cout << "\nWell done you have passed\nPress any key to exit"; cin >> One; } else cout << "\nSorry, you have failed\nPress any key to exit"; cin >> One; } ok loadsa errors fixed but wont run now? :s add a return statement to the end you bloody idiot
May 16, 200717 yr add a return statement to the end you bloody idiot done that still wont run :s http://pastebin.ca/490325
May 16, 200717 yr Author //This program rate the driver license exam //Input: test taker answer //Outputs: result //Written by: #include <fstream> void get_input_file () //open inputfile to get answer key { ifstream inputFile; inputFile.open("answerkey.txt"); } int main () // taking answers and compare with answer key { int SIZE = 21; //array size int count; char answerkey[21] = answerkey.txt; //array size for the answer key char testtaker; //array size for test taker key int totalCorrect; int maxpoint = 20 for (count = 0, count < 20, count++) { cout << "Enter the answer for question #" << count << ":"; cin << testtaker; bool test(char answerkey [count], char testtake, int count) { if (char answerkey [count] = char testtake) return true; else totalCorrect = maxpoint&& - 1; } } void displayresult () { cout << "Total score:" << totalCorrect << endl; if (totalCorrect <= 20 && totalCorrect >=15) cout << "Congratulation! You passed the writing part. Remember to get an appointment for driving part."" else cout << "Lady Luck is not with you today. Try harder next time!" } Not sure if it is right or wrong.
May 16, 200717 yr C++? jesus christ easiest prgramming language on the earth how could you fail it? You have C++ confused with Visual Basic.
May 16, 200717 yr You have C++ confused with Visual Basic. C++ is easy as hell to learn the basic stuff, but that more complicated stuff like OpenGL I try to learn and I'm like "ah shit this is hard". Simple C++ is easy as hell tho, which is what this guy's program is, easy bullshit.
May 16, 200717 yr C++? jesus christ easiest prgramming language on the earth how could you fail it? what are you stupid? OP: YOU SHOULD HAVE STUDIED ***
May 16, 200717 yr C++ is easy as hell to learn the basic stuff, but that more complicated stuff like OpenGL I try to learn and I'm like "ah shit this is hard". Simple C++ is easy as hell tho, which is what this guy's program is, easy bullshit. I know how easy the basics of C++ are. Still, overall, Visual Basic is an easier language.