Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[java] need homework help lol


lollicat
 Share

Recommended Posts

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

> 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...