Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 9:22 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 3 posts ] 
Author Question
 Question subject: need some help with array comparing program (solved)
PostPosted: Sat Nov 27, 2010 1:38 am 
Offline
Newbie
User avatar

Joined: Sat Nov 27, 2010 1:06 am
Posts: 6
Has thanked: 2 time
Have thanks: 1 time

hey, im working on this project for homework and it consists of comparing the elements of one array to another. I had it running but then i did something and it made it give an exception error.

also before i messed that up i was stuck on how to compare the 2 arrays.

any help would be lovely, thanks again!!!

**ATTACHED :sohappy:


Attachments:
File comment: there are 2 java files compressed,
drivertestfiles.zip [1.25 KiB]
Downloaded 71 times

_________________
Environmental enrichment (neural), how the brain is affected by the stimulation of its information processing provided by its surroundings.


Last edited by 3nriched on Sun Nov 28, 2010 2:05 am, edited 1 time in total.
TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: need some help with array comparing program
PostPosted: Sat Nov 27, 2010 5:43 am 
Offline
Newbie
User avatar

Joined: Thu Nov 18, 2010 11:56 am
Posts: 49
Has thanked: 0 time
Have thanks: 15 time
Ok! Finally Found The Error! :yahoo:
But I don't know is that you looking for... :swoon:

Here what I did,

I changed
Code:
private String inputted;  //inputted answers
inputted = keyboard.next();
inputted.equals(answers[index]


And Here the whole java file.
Code:
//holds methods used for drivers test
import java.util.Scanner; //scanner class import

class DriverTestMethods //class name
{

   private String[] answers = { "B", "D", "A", "A", "C", "A", "B", "A",
                        "C", "D", "B", "C", "D", "A", "D", "C",
                         "C", "B", "D", "A" }; //the real answers.
                        
   private String inputted;  //inputted answers
                        
   private String[] questions;   //displays questions.
   private int correct = 0; //holds amount of correct answers.
   private int incorrect = 0; //holds amount of incorrect answers.
   private int qcounter = 1; //counts questions til 20.
   private int index = 0;
       
   
    Scanner keyboard = new Scanner(System.in);// holds input
   
   void testBegin()
      {
         
         do
         {
            System.out.println("Question " + qcounter +" goes here");
            inputted = keyboard.next();
            
            if(inputted.equals(answers[index]))
            {
               correct++;
                                       
            }
            else
            {
               incorrect++;   
            }
               
           qcounter+=1;
           index+=1;
         }while (qcounter != 21);
         
         passed();
       }
               
   void passed()
      {
         if(correct >= 15)
         {
            System.out.println("Good job, you passed!");
            System.out.println("Correct: " + correct);
            System.out.println("Incorrect: " + incorrect);
         }         
         else
          if(incorrect >= 5)
         {   
            System.out.println("Sorry, You Suck!!");
            System.out.println("Correct: " + correct);
            System.out.println("Incorrect: " + incorrect);
         }   
         
         System.exit(0);
            
      }
   }


If you have any question ask me! :rolf:

_________________
Coding my life with Java, PHP, JavaScript, and Python



For this message the author isuru has received thanks - 2: 3nriched, msi_333
TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: need some help with array comparing program
PostPosted: Sun Nov 28, 2010 12:59 am 
Offline
Newbie
User avatar

Joined: Sat Nov 27, 2010 1:06 am
Posts: 6
Has thanked: 2 time
Have thanks: 1 time
nice dude, i actually made it passed this part earlier today but this helps me with a different problem i have now ..lol
thanks again man!

_________________
Environmental enrichment (neural), how the brain is affected by the stimulation of its information processing provided by its surroundings.


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 3 posts ] 
Quick reply


  

 Similar topics
 I need you to help me to solve this program by c++ language
 How to write a JSP Program to manipulate Last Date visited
 C C++ program help using class
 how to write a "c' program on fibannoic series
 search for string in a cell array
 Java Program for communicate PC and Mobile
 java chat program written by Mr.muhammed.
 HOW TO DO C++ PROGRAM?
 Shuffle Array
 check array contains a value using javascript

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google Adsense [Bot] and 4 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team