Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:24:29+00:00 2026-05-29T06:24:29+00:00

Ok, my program in this specific section takes a line of data from a

  • 0

Ok, my program in this specific section takes a line of data from a studentAnswer string array, the value of which would be something like TTFFTFTFTF. I am supposed to take this, and compare it against a key array, which might look like TFFFTFTFTF. A student takes a quiz, and my program calculates the points correct.

My intention is to use a separate points array to find the numeric grade for the student. The index of studentAnswer refers to a specific student. So studentAnswer[i] is TTFFTFTFTF. I use substrings to compare each individual T/F against the correct answer in key[], which would have a single T/F in each index. Then, if they are correct in their answer, I add a 1 to the correlating index in points[] and will later find the sum of points[] to find the numeric grade out of ten.

My problem here is that String origAns, used to define the student’s original answer string, is getting a Java Error cannot find Symbol. I have tried placing the instantiation of origAns within each different for loop, but I can’t get the program to work. Int i is meant to follow each specific student- I have four parallel arrays that will all log the student’s ID number, numeric grade, letter grade, and original answers. So that is the intention of i, to go through each student. Then j should be used to go through each of these original student answer strings and compare it to the correct answer…
Logically, it makes sense to me where I would put it, but java doesn’t agree. Please help me to understand this error!

for (int i = 0; i < studentAnswer.length; i++){
    String origAns = studentAnswer[i];
    for (int j = 0; j < key.length; j++){
        if (origAns.substring[j] == key[j]){
            //substring of index checked against same index of key
            points[j] = 1;
        }
        if (origAns.substring[j] != key[j]){
            points[j] = 0;
        }
    }
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:24:30+00:00Added an answer on May 29, 2026 at 6:24 am

    It sounds like you’re trying to call the substring method – but you’re trying to access it as if it were a field. So first change would be:

    if (origAns.substring(j) == key[j])
    

    Except that will be comparing string references instead of contents, so you might want:

    if (origAns.substring(j).equals(key[j]))
    

    Actually, I suspect you want charAt to get a single character – substring will return you a string with everything after the specified index:

    if (origAns.charAt(j) == key[j])
    

    … where key would be a char[] here.

    You can also avoid doing the “opposite” comparison by using an else clause instead.

    You should also indent your code more carefully, for readability. For example:

    for (int i = 0; i < studentAnswer.length; i++) {
        String origAns = studentAnswer[i];
        for (int j = 0; j < key.length; j++) {
            if (origAns.charAt(j) == key[j]) {
               points[j] = 1;
            } else {
               points[j] = 0;
            }
        }
    }
    

    And now, you can change that to use a conditional expression instead of an if/else:

    for (int i = 0; i < studentAnswer.length; i++) {
        String origAns = studentAnswer[i];
        for (int j = 0; j < key.length; j++) {
            points[j] = origAns.charAt(j) == key[j] ? 1 : 0;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm needing to program something in Applescript which I've never used, but this is
This program I'm doing is about a social network, which means there are users
This program is meant to generate a dynamic array, however it gives an access
I have a number of section items (Lesson, Info) which inherit from the common
I'm using visual studio to program this small TcpServer. It's really specific. The server
Ok, first off, I didn't program this page with frames! I'll be getting rid
This program I use has it's own variables to set when you run it,
This program stores pairs in a map, counting the number of times a word
This program reads emails (really just a .txt file structured like an email) and
For this program #include <iostream> using std::cout; struct C { C() { cout <<

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.