lollicat Posted January 8, 2013 Author Share Posted January 8, 2013 This is my assignment: [https://sites.google.com/site/hdjcomputerprogramming/home/unit-7/06-grading-quizzes](https://sites.google.com/site/hdjcomputerprogramming/home/unit-7/06-grading-quizzes)And this is what I have so far:```import java.util.Scanner;public class gradingQuizzes{ public static void main(String[] args) { int numOfQs; String key; Scanner scan = new Scanner(System.in); Scanner scanLine = new Scanner(System.in); System.out.print("How many questions are in the quiz? "); numOfQs = scan.nextInt(); System.out.print("Please enter the key (separated by spaces): "); key = scanLine.nextLine(); String[] answers = new String[numOfQs]; for (int x=0; x < numOfQs; x++); { } }}```I honestly just don't know what to do for this. Don't tell me the code, just telling me what I need to accomplish here and maybe how would be great. Thank you ![B)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/cool.png) Link to comment Share on other sites More sharing options...
AeroEBrown Posted January 8, 2013 Share Posted January 8, 2013 > This is my assignment: [https://sites.google…grading-quizzes](https://sites.google.com/site/hdjcomputerprogramming/home/unit-7/06-grading-quizzes)> > And this is what I have so far:> > ```> > import java.util.Scanner;> > public class gradingQuizzes> > {> > public static void main(String[] args)> > {> > > > int numOfQs;> > String key;> > Scanner scan = new Scanner(System.in);> > Scanner scanLine = new Scanner(System.in);> > > > System.out.print("How many questions are in the quiz? ");> > numOfQs = scan.nextInt();> > > > System.out.print("Please enter the key (separated by spaces): ");> > key = scanLine.nextLine();> > > > String[] answers = new String[numOfQs];> > > > for (int x=0; x < numOfQs; x++);> > {> > > > > > > > }> > > > }> > }> > ```> > I honestly just don't know what to do for this. Don't tell me the code, just telling me what I need to accomplish here and maybe how would be great. Thank you ![B)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/cool.png)First off make the key an array the same size as the number of questions. Then just read each key answer as an int. And don't make two scanners. You only need one.Then create an integer array for the sum of the correct answers and an integer for the total responses. The array sizes are the same as the number of questions.In the loop, ask the user to enter the answers for each question, if the answer is correct add to the correct answers integer for that question and then add one to the total responses.At the end, just print each question's number, the number correct and the percent correct.Thanks,EBrown Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now