Handling Arrays with Students Grades

Can anyone help!
I am traying to compile program Grade2 which processes student assignment marks to determine how many students obtained each of possible grades: 1 to 5. The user enters each grade as an integer and to mark the end of the data stream a 0 or negative number. One should use suitable array to hold the numbers of students with each grade.
This is what I compiled so far:
import java.io.*;
class Grade2
     public static void main(String[]args)
     throws IOException
          int grade2, count[];
     System.out.println ("Input a grade");
          grade2=Course_io.readInt();
          for (int i=0; i<5; i++)
          while (grade2>0)
               if (grade2==1)
                    count[0]=1;
               else if (grade2==2)
                    count[1]=2;
               else if (grade2==3)
                    count[2]=3;
               else if (grade2==4)
                    count[3]=4;
               else if (grade2==5)
                    count[4]=5;
               else if (grade2>5)
                    System.out.println("Enter correct grade");
     System.out.println ("Input a grade");
               grade2=Course_io.readInt();
     System.out.println("The result is "+count[0]);
     System.out.println("The result is "+count[1]);
     System.out.println("The result is "+count[2]);
     System.out.println("The result is "+count[3]);
     System.out.println("The result is "+count[4]);
When compiling this program shows two errors: refering to: grade2=Course__io.read.Int();
I do not know where I am doing wrong?
emni

Dear Joni Salonen,
Thank you for last reply, it was a error of capital letter G for grades2, as you rightly noted. Now it complies fine but still does not do the task, eg I am supose to count a number of students with each grade and store them in the array, this rutine only notes array elements index for grade entered not a number of students with that grade. Please refer back to the original code and advise what to do to reflect this task. This is a repeat of the code:
import java.io.*;
class grade2
     public static void main(String[]args)
     throws IOException
          int grade2, count[];
          System.out.println ("Input a grade");
          grade2=Course_io.readInt();
          count = new int[5];
          for (int i=0; i<5; i++)
          while (grade2>0)
               if (grade2==1)
                    count[0]=1;
               else if (grade2==2)
                    count[1]=2;
               else if (grade2==3)
                    count[2]=3;
               else if (grade2==4)
                    count[3]=4;
               else if (grade2==5)
                    count[4]=5;
               else if (grade2>5)
                    System.out.println("Enter correct grade");
               System.out.println ("Input a grade");
               grade2=Course_io.readInt();
          System.out.println("Number of Grades no 1 is "+count[0]);
          System.out.println("Number of Grades no 2 is "+count[1]);
          System.out.println("Number of Grades no 3 is "+count[2]);
          System.out.println("Number of Grades no 4 is "+count[3]);
          System.out.println("Number of Grades no 5 is "+count[4]);
Thanks!
emni

Similar Messages

  • Handling arrays with objects

    well i have 2 classes a driver and a object creator....
    i create an object with 4 arrays inside
    the arrays are user, mail, password, diskspace
    i need to make a sorting method inside my class so the arrays are displayed in alphabetical order but i just dont know how i can make it... here i post everything i have done
    import java.io.*;
    public class FinalDriver{
        public static void main (String[] args) throws IOException{
            BufferedReader stdIn = new BufferedReader (new InputStreamReader (System.in));       
            PrintWriter stdOut = new PrintWriter(System.out, true);       
            char option;
            boolean flag;       
            int count = 0;
            FinalClass accounts = new FinalClass();
            do{
                menu();
                option = stdIn.readLine().toUpperCase().charAt(0);
                flag = designation(option, accounts, count);
            while (!flag);
            stdOut.println("Finished");   
            public static void menu(){
            PrintWriter stdOut = new PrintWriter(System.out, true);
            stdOut.println ("***********************");
            stdOut.println ("*    E-mail Service   *");
            stdOut.println ("*---------------------*");
            stdOut.println ("*                     *");
            stdOut.println ("*  A) Add new user    *");
            stdOut.println ("*  B) Display stats.  *");
            stdOut.println ("*  C) Sort by name    *");
            stdOut.println ("*  *) Exit            *");
            stdOut.println ("*                     *");
            stdOut.println ("*---Choose a letter---*");           
            stdOut.println ("***********************");   
            public static boolean designation (char option, FinalClass accounts, int count) throws IOException{
                PrintWriter stdOut = new PrintWriter(System.out, true);
            switch (option){
                case 'A':{
                    newUser(accounts , count);
                    return false;
                case 'B':{
                    displayStats(count, accounts);
                    return false;
                case 'C':{
                    sortInfo(count, accounts);
                    return false;
                case '*':{
                    return true;
                default:{
                    stdOut.println("Invalid input");   
                    return false;
            public static void newUser(FinalClass accounts, int count) throws IOException{
                BufferedReader stdIn = new BufferedReader (new InputStreamReader (System.in));
                PrintWriter stdOut = new PrintWriter(System.out, true);
                RandomStringUtils randomPassword = new RandomStringUtils();
                String name, password, email;
                double diskSpace;
                char nameChar, passChar;
                stdOut.println("You have selected new user");
                stdOut.println("What will the username be?");
                name = stdIn.readLine();
                nameChar= name.charAt(0);
                while(nameChar != '*'){           
                    stdOut.println("Do tou want to create the password?");
                    passChar= stdIn.readLine().toUpperCase().charAt(0);
                    if(passChar == 'Y')
                        password= stdIn.readLine();
                    else
                        password= passwordMethod(randomPassword);   
            stdOut.println("What will the email be?");
            email= stdIn.readLine();
            stdOut.println("how much disk space is used?");
            diskSpace= Double.parseDouble(stdIn.readLine());
            accounts.newUser(name, password, email, diskSpace, count);
            stdOut.println("What will the username be?");
            name = stdIn.readLine();
            nameChar= name.charAt(0);
            count = count + 1;
            public static void displayStats(int count, FinalClass accounts){
                PrintWriter stdOut = new PrintWriter(System.out, true);
            stdOut.println("You have chosen the Display Statistics option");
            public static void sortInfo(int count, FinalClass accounts){
                PrintWriter stdOut = new PrintWriter(System.out, true);
            stdOut.println("You have chosen the Sort Information option");
            accounts.printString(count, accounts);   
            public static String passwordMethod(RandomStringUtils randomPassword){
                String password;
                password = randomPassword.randomAlphanumeric(8);
                System.out.println("yor password is: "+ password);
                return password;
    public class FinalClass
       private String [] user = new String[100];
       private String [] mail = new String[100];
       private String [] password = new String[100];
       private double [] diskSpace = new double[100];
       private int count;
       public FinalClass(){
          for(count= 0; count<100; count =count +1){
              user[count]= "-1";
              mail[count]= "-1";
              password[count]= "-1";
              diskSpace[count]= -1;
       public void newUser(String tempName, String tempPassword, String tempEmail, double tempDiskSpace, int counting){
                  user[counting]= tempName;
                  password[counting]=tempPassword;
                  mail[counting]=tempEmail;
                  diskSpace[counting]=tempDiskSpace;
       public void printString (int count, FinalClass accounts){
           for(int i = 0; count > i; i = i + 1){
               System.out.print(user[i] + "     ");
               System.out.print(mail[i] + "     ");
               System.out.print(password[i] + "     ");
               System.out.println(diskSpace[i] + "     ");

    a friend of mine explained me that -1 is returned if the first value is bigger than the second 0 if they are the same and 1 if the second is bigger( bigger meaning in ascci)
    then, i need to do a while loop with a for inside that leads to an if statment.. am i right?
    public void printString (int count, FinalClass accounts){
            boolean flag = true;
            String tempString;
            double tempDouble;
            int intFlag;
            while (flag){
                 flag = false;
                 for(int i = 0; count > i ; i = i + 1){
                      intFlag = user.compareToIgnoreCase(user[i+1]);
                   if (-1){
                   else{
         }i just dont know what to put in the if statmente                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to initialize the array with object?

    Here is type I have.
    CREATE OR REPLACE TYPE SYSADM.AP_COMMENT_TYPE AS OBJECT
    BU_AP VARCHAR2(5),
    VOUCHER VARCHAR2(10),
    V_LINE INTEGER,
    USERID VARCHAR2(20),
    COMMENT_DTTM DATE,
    COMMENT VARCHAR2(254)
    CREATE OR REPLACE TYPE SYSADM.AP_COMMENT_COLL AS VARRAY(1000) OF SYSADM.AP_COMMENT_TYPE;
    Then I created a procedure to grab some data.
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed
    FROM ps_fas_ap_comment
    WHERE business_unit = voucher_comment (i).bu_ap
    AND voucher_id = voucher_comment (i).voucher;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed
    FROM ps_fas_ap_comment
    WHERE business_unit = voucher_comment (i).bu_ap
    AND voucher_id = voucher_comment (i).voucher
    AND voucher_line_num = voucher_comment (i).v_line;
    BEGIN
    voucher_comment (1) := ap_comment_type (' ', ' ', 0, ' ', '', ' ');
    --voucher_comment (1) := ap_comment_type (null, null, null, null, null,null);
    IF voucher_comment (i).v_line = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              voucher_comment.EXTEND;
    voucher_comment (i) :=
    ap_comment_type (v_bu_in,
    v_voucher_in,
    v_line_num,
    v_userid,
    TO_DATE (TO_CHAR (SYSDATE,
    'DD-MON-YYYY HH24:MI:SS'
    'DD-MON-YYYY HH24:MI:SS'
    v_comments
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.EXTEND;
    voucher_comment (i) :=
    ap_comment_type (v_bu_in,
    v_voucher_in,
    v_line_num,
    v_userid,
    TO_DATE (TO_CHAR (SYSDATE,
    'DD-MON-YYYY HH24:MI:SS'
    'DD-MON-YYYY HH24:MI:SS'
    v_comments
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;
    But when I tried to test the procedure, got error: ORA-06531: Reference to uninitialized collection. Does anyone have experience of handling array with object?
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL;
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 1, 'KEHE', O_voucher_comment);
    end;

    Thanks for that. I changed it a little bit, but when i ran this script, got ORA-06532: Subscript outside of limit.
    declare
    O_voucher_comment SYSADM.AP_COMMENT_COLL := sysadm.ap_comment_coll(null);
    begin
    FAS_AP_EXCEPTIONS.GET_VOUCHER_COMMENTS('FCCAN', '20494753', 0, 'KEHE', O_voucher_comment);
    end;
    PROCEDURE get_voucher_comments (
    v_bu_in IN VARCHAR2,
    v_voucher_in IN VARCHAR2,
    v_line_in IN NUMBER,
    v_userid IN VARCHAR2,
    voucher_comment OUT      sysadm.ap_comment_coll
    IS
    i NUMBER := 1;
    v_comments VARCHAR2 (254) := ' ';
    comment_type sysadm.ap_comment_type;
    v_line_num NUMBER := 0;
    CURSOR get_all_comment
    IS
    SELECT voucher_line_num, descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in;
    CURSOR get_line_comment
    IS
    SELECT descr254_mixed FROM ps_fas_ap_comment
    WHERE business_unit = v_bu_in AND voucher_id = v_voucher_in
    AND voucher_line_num = v_line_in;
    BEGIN
    --voucher_comment() := SYSADM.ap_comment_type (NULL, NULL, NULL, NULL, NULL, NULL);
    --' ', ' ', 0, ' ', '', ' ' sysadm.ap_comment_coll
    voucher_comment := sysadm.ap_comment_coll(null);
    IF v_line_in = 0
    THEN
    OPEN get_all_comment;
    LOOP
    FETCH get_all_comment
    INTO v_line_num, v_comments;
              if i > 1
              then
                   voucher_comment.EXTEND;
              end if;
    voucher_comment (i) := ap_comment_type (v_bu_in,
    v_voucher_in, v_line_num, v_userid,
    TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS'), 'DD-MON-YYYY HH24:MI:SS'), v_comments );
    i := i + 1;
    END LOOP;
    ELSE
    OPEN get_line_comment;
    LOOP
    FETCH get_line_comment
    INTO v_comments;
              voucher_comment.extend(6);
    voucher_comment (i) := ap_comment_type (v_bu_in, v_voucher_in, v_line_num, v_userid, TO_DATE (TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS' ), 'DD-MON-YYYY HH24:MI:SS'), v_comments);
    i := i + 1;
    END LOOP;
    END IF;
    END get_voucher_comments;

  • I'm using numbers for my students grades. the passing grade is 30 points. what i want to happen is that very students with a grade of less than 30 will have their points it red color. does the IF function can do this? how?

    i'm using numbers for my students grades. the passing grade is 30 points. what i want to happen is that very students with a grade of less than 30 will have their points it red color. does the IF function can do this? how?

    Hi efren
    Conditional format will do this.
    Select the Cells, then Menu > Format > Show Conditional Format Rules
    Regards,
    Ian.

  • I have read 118 files (from a directory) each with 2088 data and put them into a 2 D array with 2cols and 246384row, I want to have aeach file on a separate columns with 2088 rows

    I have read 118 files from a directory using the list.vi. Each file has 2 cols with 2088rows. Now I have the data in a 2 D array with 2cols and 246384rows (118files * 2088rows). However I want to put each file in the same array but each file in separate columns. then I would have 236 columns (2cols for each of the 118 files) by 2088 rows. thank you very much in advance.

    Hiya,
    here's a couple of .vi's that might help out. I've taken a minimum manipulation approach by using replace array subset, and I'm not bothering to strip out the 1D array before inserting it. Instead I flip the array of filenames, and from this fill in the end 2-D array from the right, overwriting the column that will eventually become the "X" data values (same for each file) and appear on the right.
    The second .vi is a sub.vi I posted elsewhere on the discussion group to get the number of lines in a file. If you're sure that you know the number of data points is always going to be 2088, then replace this sub vi with a constant to speed up the program. (by about 2 seconds!)
    I've also updated the .vi to work as a sub.vi if you wa
    nt it to, complete with error handling.
    Hope this helps.
    S.
    // it takes almost no time to rate an answer
    Attachments:
    read_files_updated.vi ‏81 KB
    Num_Lines_in_File.vi ‏62 KB

  • Fill Array with all possible combinations of 0/1

    Hi,
    i'm looking for a fast way to fill an array, respectively an int[8], with all possible combinations of 0 and 1 (or -1 and 1, shouldn't make a difference).
    I kind of know how to do it using multiple loops but I assume there is a more elegant or at leaster "better" practice.
    Thanks,
    nikolaus
            static int cnt = 0;
         public static void main(String[] args) {
              int[] element = new int[]{1,1,1,1,1,1,1,1};
              Integer[] x = new Integer[2];
              x[0] = 1;
              x[1] = -1;
              for(int i7:x){
                   element[7] = i7;
                   for(int i6:x){
                        element[6] = i6;
                        for(int i5:x){
                             element[5] = i5;
                             for(int i4:x){
                                  element[4] = i4;
                                  for(int i3:x){
                                       element[3] = i3;
                                       for(int i2:x){
                                            element[2] = i2;
                                            for(int i1:x){
                                                 element[1] = i1;
                                                 for(int i0:x){
                                                      element[0] = i0;
                                                      cnt++;
              }Edited by: NikolausO on Oct 30, 2008 4:21 AM
    Edited by: NikolausO on Oct 30, 2008 4:22 AM

    pm_kirkham wrote:
    No I replied to message number 5. as the ' (In reply to #5 )' above my post indicates, which was in reply to (a reply) to Sabre150's post which wasn't using enhanced loops, nor has any obvious place where you could use that approach to fill the array.
    Though you could pass in an array of the values to fill the array with, and loop over those, instead of using 0 or 1, at which point Sabre's approach becomes the same as your OP, but without the manual unrolling:
    import java.util.Arrays;
    public class NaryCombinations {
    public interface CombinationHandler {
    void apply (int[] combination) ;
    public static void main(String[] args) {
    calculateCombinations(new int[]{-1, 0, 1}, 4, new CombinationHandler () {
    public void apply (int[] combination) {
    System.out.println(Arrays.toString(combination));
    public static void calculateCombinations (int[] values, int depth, CombinationHandler handler) {
    recursivelyCalculateCombinations(values, 0, depth, handler, new int[depth]);
    private static void recursivelyCalculateCombinations (int[] values, int index, int depth,
    CombinationHandler handler, int[] combination) {
    if (index == depth) {
    handler.apply(combination);
    } else {
    for (int value : values) {
    combination[index] = value;
    recursivelyCalculateCombinations(values, index + 1, depth, handler, combination);
    Which looks to use the same basic approach to the generalization I created shortly after posting the original.
    public class Scratch1
         * A 'callback' to be invoked with every combination
         * of the result.
        public interface Callback
             * Invoked for each combination.
             * <br>
             * Each call is passed an new instance of the array.
             * @param array the array containing a combination.
            void processArray(int[] array);
        public Scratch1(final int[] array, final Callback callback, final int... values)
            if (callback == null)
                throw new IllegalArgumentException("The 'callback' cannot be 'null'");
            if (array.length < 1)
                throw new IllegalArgumentException("The array length must be >= 1");
            if ((values == null) || (values.length < 1))
                throw new IllegalArgumentException("The 'values' must have be at least of length 2");
            callback_ = callback;
            values_ = values.clone();
            array_ = array;
        public Scratch1(final int order, final Callback callback, final int... values)
            this(new int[order], callback, values);
         * Generates every possible value and invokes the callback for each one.
        public void process()
            process(0);
         * Internal method with no logical external use.
        private void process(int n)
            if (n == array_.length)
                callback_.processArray(array_.clone());
            else
                for (int v : values_)
                    array_[n] = v;
                    process(n + 1);
        private final Callback callback_;
        private final int[] values_;
        private final int[] array_;
        public static void main(String[] args) throws Exception
            final Callback callback = new Callback()
                public void processArray(int[] array)
                    System.out.println(java.util.Arrays.toString(array));
            new Scratch1(6, callback, 2, 1, 0).process();

  • Synchronis​e time in array with the real time from computer

    i need help in syrnchonising my array and the real time running in my computer
    As stated in the text file attached,
    12:32:30 AM 0.38 1.14
    2nd column is wind speed, 3rd is gust speed.
    i would like to display the wind speed in a gauge with the right values. like for example, at 12:32:30 AM OF REAL TIME, NOT BASED ON THE TEXT, i would like to display the 0.38m's of wind speed in the gauge.
    how do i sync the time in array with the real-time?
    i have attached a program i made so far. its abit messy. im still a student, need a lil help
    Attachments:
    Wind Speed and Gust Speed.txt ‏13 KB
    Time and MaxMin.vi ‏18 KB

    wali123 wrote:
    wat u mean duplicate?
    Don't continually post the same question over and over. If you have new information, add it to the original thread. Did you actually click the link under the word "duplicate"?
    Chopping up a discussion about the same thing into several threads (like here is this thread, but also here and here) serves no useful purpose. It will not increase the chance of a good answer, in fact most people will simply ignore it.
    Imagine if everybody else would post like you! Every discussion would be if three different places and we would have three times more threads.
    LabVIEW Champion . Do more with less code and in less time .

  • Student grades query of two courses

    Hi everybody
    I need some advices from experts. I'm trying to make a suitable database for students grades. I'm a bit confused in how to gather all grades of each single student into one from. let say that the students have two courses, where each course has 4 tests. The
    4 tests of the two courses are summed separately, so we will have two total grades. Finally, the average of the two grades is considered as the final grade. Here I would like inquire, should I create one query for all grades or it is better to create a query
    for each course grades then create a third query to gather the two queries. Note that I need to print out the first course grade (including the tests ). Also, In the second course I will have to print out the whole grades in details for the two courses. 
    Any help please.
    Thanks in advance.

    Amending the model for one of my online demos, StudentCouses.zip in my public databases folder at:
    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
    to include tests gives the following model:
    With this the final grade per student can be returned with the following query:
    SELECT StudentID, FirstName, LastName,
    AVG(TotalGrades) AS FinalGrade
    FROM
        (SELECT Students.StudentID, FirstName, LastName,CourseName,
         SUM(StudentCourseTests.Grade) AS TotalGrades
         FROM (Courses INNER JOIN Tests ON Courses.CourseID = Tests.CourseID)
         INNER JOIN (Students INNER JOIN StudentCourseTests
         ON Students.StudentID = StudentCourseTests.StudentID)
         ON (Tests.CourseID = StudentCourseTests.CourseID)
         AND (Tests.Test = StudentCourseTests.Test)
         GROUP BY Students.StudentID, FirstName, LastName,CourseName) AS sqTotalGrades
    GROUP BY StudentID, FirstName, LastName;
    It would be a simple task to create a report based on the tables and return the individual grades per student per test, along with the sums of grades per test in a group footer, and the final grades in a subreport based on the above query.
    Ken Sheridan, Stafford, England
    Ken Sheridan,
    That is great. However, can I make a class table and then the link it to the student table as (one to many )?

  • Reading file as 2d array with scanner

    im having trouble with this assignment, creating methods is confusing me i dont get what im supposed to put in the parentheses following them.. and i also cant figure out much else anyway. if someone could give me some step by step on how to complete this - i dont just want someone to do it for me i'd like to know how its done so i can actually learn this >.<
    below is instructions for my assignment.
    ~~~~
    Authentication
    You were hired to be part of team developing an application that requires users to login and be authenticated with a password. Your specific job is to write the authentication part of the system. This requires the beginning of the application that prompts the user for a login and password, verifies if it correctly matches the pair stored in a file, and reports back if it was successful or not.
    Since your part of the application is only the beginning of a much larger program, you will be required to write the authentication code in a seperate class. This seperate class is to be called Authenticate.
    The Authenticate class will need 1 instance variable only:
    * a 2-D array with a maximum of 10 logins possible (reference a constant that YOU define for the number 10).
    The Authenticate class will need 3 methods created:
    * Authenticate - constructor method that takes a String as a parameter which is the name of the file to be read in that contains the login/password pairs.
    This method should instantiate the 2-D array of login/password pairs and call the loadPasswordFile method by sending the name of the file.
    * loadPasswordFile - method that takes a String as a parameter which is the name of the file to be read in. When you open the file in this method, you'll need to catch errors that Java may throw - put the code within a try...catch block.
    Example:
                    try
                         // put code here that may throw an error
                    } catch ( Exception e )
                         // do whatever to handle the error
                    }           For more info, see Exceptions in Java textbook.
    Each line in the file is a login/password pair, separated with a semi-colon. You have lots of options on how to parse them.
    Store the pair in the 2-D array (instance variable).
    This method should be private since outside classes should not be able to access it.
    Example password file:
              CookieMonster;qwerty
              liz;jkl
    * verify - takes two String parameters - the login name and passwords.
    Returns an integer ID number of whether or not login matches the password or there's an error.
    Method walks through the 2-D array of login/password pairs and searches for a match to the login name parameter. If they match, check and verify that the password matches. Return an appropriate error identifier if the login doesn't exist or the password doesn't match.
    Note: There may not be 10 name/passwords in the file, but your code should still work - HINT: check for null.
    Example output
    Run without any command-line arguments:
    Usage: CVS passwordFileName
    Run with command-line argument pswds which is the file containing login/password pairs
    You are entering a secure site.
    What is your login name: liz
    What is your password: jkl
    Good to go! Welcome back liz
    You are entering a secure site.
    What is your login name: CookieMonster
    What is your password: qwerty
    Good to go! Welcome back CookieMonster
    You are entering a secure site.
    What is your login name: liz
    What is your password: aaaaaaaaah
    Password doesn't match. Good bye.
    You are entering a secure site.
    What is your login name: java
    What is your password: jkl
    Login does not exist. Good bye.
    The CVS class with main method
    In the main program class you will have the main method that is executed when the program runs (you cannot run the Authenticate class). You will also need to create a support method in this class that handles the prompting of the user for their login and password.
    The skeleton of the CVS class is provided. DO NOT CHANGE IT IN ANY WAY! You are only to add to the promptUser method.import java.awt.*;
    import java.util.*;
    import java.io.*;
    /* Program a control version software program */
      public class CVS
            static Authenticate auth;                    // class variable
               public static void main( String args[])
                if( args.length != 1 )               // didn't run program right
                  System.out.println( "Usage: CVS  passwordFileName" );
                   return;
               auth = new Authenticate( args[0] );
              promptUser( );
           /** Method to prompt the user for login and password,
              read in the values, then call the verify method
              in Authenticate to verify login and password matches
              or verify returns an error identifier and will print
              either success or error message.
              PRE-conditions: none
              POST-conditions: prints success or error message
           private static void promptUser( )
              // add your code here, reference the auth class variable
      }~~~~

    I pass him/her to the mouths of the horrible predators, a.k.a. assignment poster bashers, hanging out on the forum.

  • How to handle dbms_xmldom with no data values.(no_data_found error in dom)

    hi,
    i have below block,
    DECLARE
    doc dbms_xmldom.DOMDocument;
    node dbms_xmldom.DOMNode;
    elem dbms_xmldom.DOMElement;
    cur_node dbms_xmldom.DOMNode;
    root_elem_data dbms_xmldom.DOMElement;
    root_elem_tab dbms_xmldom.DOMElement;
    root_node_data dbms_xmldom.DOMNode;
    mode_elmn dbms_xmldom.DOMElement;
    mode_node dbms_xmldom.DOMNode;
    mode_text dbms_xmldom.DOMText;
    doc1 DBMS_XMLDOM.DOMDOCUMENT;
    root_node_data1 DBMS_XMLDOM.DOMNODE;
    child_document DBMS_XMLDOM.DOMDOCUMENT;
    child_rootnode DBMS_XMLDOM.DOMNODE;
    V_CLOB CLOB;
    v_doc CLOB;
    v_EMP CLOB;
    v_output_filename VARCHAR2(300) := 'SPOOL_DIR/'||'EMP_XML_FILE.xml';
    l_xmltype XMLTYPE;
    BEGIN
    doc := dbms_xmldom.newDOMDocument;
    node := dbms_xmldom.makeNode(doc);
    dbms_xmldom.setversion(doc, '1.0');
    dbms_xmldom.setCharset(doc, 'UTF8');
    elem := dbms_xmldom.createElement(doc, 'PartnerInfo');
    dbms_xmldom.setAttribute(elem,'xmlns','EMP');
    cur_node := dbms_xmldom.appendChild(node, dbms_xmldom.makeNode(elem));
    mode_elmn := dbms_xmldom.createElement(doc, 'EMPLOYEE');
    mode_node := dbms_xmldom.appendChild(cur_node,dbms_xmldom.makeNode(mode_elmn));
    BEGIN
    SELECT value(e) INTO l_xmltype
    FROM TABLE(XMLSequence(Cursor(SELECT * FROM EMP1 where EMPNO=7501))) e;
    child_document := DBMS_XMLDOM.newDOMDocument(l_xmltype);
    root_node_data1 := dbms_xmldom.importNode(doc,dbms_xmldom.makeNode(dbms_xmldom.getDocumentElement(child_document)),TRUE);
    root_node_data1 := DBMS_XMLDOM.appendChild(root_node_data, root_node_data1);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    dbms_lob.createtemporary(v_doc, true);
    dbms_xmldom.writeToClob(doc,v_doc,'UTF8');
    v_EMP:= v_doc;
    dbms_xmldom.writeToFile(DOC,v_output_filename,'UTF8');
    dbms_xmldom.freeDocument(doc);
    --Dbms_Output.Put_Line('THE OUTPUT IS::'||V_EMP);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    The xml file is 'EMP_XML_FILE.xml'
    <empno>U++kYmcVuGchxbh+++++++++++++++1+</empno>
    <empname>J</empname>
    suppose the empno 7501 is not available in our emp table,
    i got error
    ORA-03113: end-of-file on communication channel
    how to handle xmldom with no data values.
    by
    siva

    hi,
    please give the solution
    by
    siva

  • Lots of blank space when printing array with only last element printed

    I have a slight problem I have been trying to figure it out for days but can't see where my problem is, its probably staring me in the face but just can't seem to see it.
    I am trying to print out my 2 dimensional array outdie my try block. Inside the trying block I have two for loops in for the arrays. Within the second for loop I have a while to put token from Stringtokeniser into my 2 arrays. When I print my arrays in this while bit it prints fine however when I print outside the try block it only print the last element and lots of blank space before the element.
    Below is the code, hope you guys can see the problem. Thank you in advance
       import java.io.*;
       import java.net.*;
       import java.lang.*;
       import java.util.*;
       import javax.swing.*;
       public class javaflights4
          public static final String MESSAGE_SEPERATOR  = "#";
          public static final String MESSAGE_SEPERATOR1  = "*";
          public static void main(String[] args) throws IOException
             String data = null;
             File file;
             BufferedReader reader = null;
             file = new File("datafile.txt");
             String flights[] [];
                   //String flightdata[];
             flights = new String[21][7];
             int x = 0;
                   //flightdata = new String[7];
             int y = 0;
             try
                reader = new BufferedReader(new FileReader(file));   
                //data = reader.readLine();   
                while((data = reader.readLine())!= null)   
                   data.trim();
                   StringTokenizer tokenised = new StringTokenizer(data, MESSAGE_SEPERATOR1);
                   for(x = 0; x<=flights.length; x++)
                      for(y = 0; y<=flights.length; y++)
                         while(tokenised.hasMoreTokens())
                            //System.out.println(tokenised.nextToken());
                            flights [x] [y] = tokenised.nextToken();
                            //System.out.print("*"+ flights [x] [y]+"&");
                   System.out.println();
                catch(ArrayIndexOutOfBoundsException e1)
                   System.out.println("error at " + e1);
                catch(Exception e)
                finally
                   try
                      reader.close();
                      catch(Exception e)
             int i = 0;
             int j = 0;
             System.out.print(flights [j]);
    //System.out.println();

    A number of problems.
    First, I bet you see a lot of "error at" messages, don't you? You create a 21x7 array, then go through the first array up to 21, going through the second one all the way to 21 as well.
    your second for loop should go to flights[x].length, not flights.length. That will eliminate the need for ArrayIndexOutOfBounds checking, which should have been an indication that you were doing something wrong.
    Second, when you get to flights[0][0] (the very first iteration of the inner loop) you are taking every element from the StringTokenizer and setting flights[0][0] to each, thereby overwriting the previous one. There will be nothing in the StringTokenizer left for any of the other (21x7)-1=146 array elements. At the end of all the loops, the very first element in the array (flights[0][0]) should contain the last token in the file.
    At the end, you only print the first element (i=0, j=0, println(flight[ i][j])) which explains why you see the last element from the file.
    I'm assuming you have a file with 21 lines, each of which has 7 items on the line. Here is some pseudo-code to help you out:
    count the lines
    reset the file
    create a 2d array with the first dimension set to the number of lines.
    int i = 0;
    while (read a line) {
      Tokenize the line;
      count the tokens;
      create an array whose size is the number of tokens;
      stuff the tokens into the array;
      set flights[i++] to this array;
    }

  • How can I make Keynote files read-only (eg: to share with students)?

    I would like to share some keynote files with students, and I would like to set them up as read-only, so that the students can tap the screen, read my presentation, but not alter it.  I've tried to set the files up as read-only on my iMac desktop, but when I load the file onto my iPad, it's still editable.
    Any ideas re: how to make Keynote files read-only?
    I've tried to export the files as PDF and load them into iBook, but some of Keynote's basic "build" functions won't work this way.  Specifically, I have files set up with questions and answers (ie - a question appears, and you have to tap the screen to see the answer, but this "build" function seems to disappear when I get it to show up in iBook).
    Any ideas how to make Keynote files read-only?  I am happy to use another program, but I want the students to tap the screen in order to see the answer to a question.
    Thanks!

    as long as $PATH is set, you shouldn't need to reconnect them (i think).  if you send the list of apps through | awk -F '/' '{print $NF}' | that'll strip the path
    /edit: added the "(i think)" part
    Last edited by brisbin33 (2009-06-02 21:33:06)

  • Auto-indexing is slow for arrays with 1 dimensions

    Hi,
    I was looking at the performance of operations on all individual elements in 3D arrays, especially the difference between auto-indexing (left image) and manual-indexing (right image, calling "Index array" and "Replace array subset" in the innermost loop). I'm a bit puzzled by the results and post it here for discussion and hopefully somebody's benefit in the future.
    Left: auto-indexing; right: manual-indexing
    In the tests I added a different random number to all individual elements in a 3D array. I found that auto-indexing is 1.2 to 1.5 times slower than manual-indexing. I also found that the performance of auto-indexing is much more dependent on the size the dimensions: an array with 1000x200x40 elements is 20% slower than an array with 1000x40x200 elements. For manual-indexing there is hardly any difference. The detailed results can be found at the end of this post.
    I was under the impression that auto-indexing was the preferred method for this kind of operation: it achieves exactly the same result and it is much clearer in the block diagram. I also expected that auto-indexing would have been optimized in LabView, but the the tests show this is clearly not the case.
    What is auto-indexing doing?
    With two tests I looked at how auto-index works.
    First, I looked if auto-indexing reorganizes the data in an inefficient way. To do this I made a method "fake-auto-indexing" which calls "Array subset" and "Reshape array" (or "Index array" for a 1D-array) when it enters _every_ loop and calls "Replace array subset" when exiting _every_ loop (as opposed to manual-indexing, where I do this only in the inner loop). I replicated this in a test (calling it fake-auto-indexing) and found that the performance is very similar to auto-indexing, especially looking at the trend for the different array lengths.
    Fake-auto-indexing
    Second, I looked if Locality of reference (how the 3D array is stored in memory and how efficiently you can iterate over that) may be an issue. Auto-indexing loops over pages-rows-columns (i.e. pages in the outer for-loop, rows in the middle for-loop, columns in the inner for-loop). This can't be changed for auto-indexing, but I did change it for manual and fake-indexing. The performance of manual-indexing is now similar to auto-indexing, except for two cases that I can't explain. Fake-auto-indexing performs way worse in all cases.
    It seems that the performance problem with auto-indexing is due to inefficient data organization.
    Other tests
    I did the same tests for 1D and 2D arrays. For 1D arrays the three methods perform identical. For 2D arrays auto-indexing is 15% slower than manual-indexing, while fake-auto-indexing is 8% slower than manual-indexing. I find it interesting that auto-indexing is the slowest of the three methods.
    Finally, I tested the performance of operating on entire columns (instead of every single element) of a 3D array. In all cases it is a lot faster than iterating over individual elements. Auto-indexing is more than 1.8 to 3.4 times slower than manual-indexing, while fake-auto-indexing is about 1.5 to 2.7 times slower. Because of the number of iterations that has to be done, the effect of the size of the column is important: an array with 1000x200x40 elements is in all cases much slower than an array with 1000x40x200 elements.
    Discussion & conclusions
    In all the cases I tested, auto-indexing is significantly slower than manual-indexing. Because auto-indexing is the standard way of indexing arrays in LabView I expected the method to be highly optimized. Judging by the tests I did, that is not the case. I find this puzzling.
    Does anybody know any best practices when it comes to working with >1D arrays? It seems there is a lack of documentation about the performance, surprising given the significant differences I found.
    It is of course possible that I made mistakes. I tried to keep the code as straightforward as possible to minimize that risk. Still, I hope somebody can double-check the work I did.
    Results
    I ran the tests on a computer with a i5-4570 @ 3.20 GHz processor (4 cores, but only 1 is used), 8 GB RAM running Windows 7 64-bit and LabView 2013 32-bit. The tests were averaged 10 times. The results are in milliseconds.
    3D-arrays, iterate pages-rows-columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 : 268.9   202.0   268.8
       40 x 1000 x  200 : 276.9   204.1   263.8
      200 x   40 x 1000 : 264.6   202.8   260.6
      200 x 1000 x   40 : 306.9   205.0   300.0
     1000 x   40 x  200 : 253.7   203.1   259.3
     1000 x  200 x   40 : 307.2   206.2   288.5
      100 x  100 x  100 :  36.2    25.7    33.9
    3D-arrays, iterate columns-rows-pages
    pages x rows x cols : manual  fake
       40 x  200 x 1000 : 277.6   457       
       40 x 1000 x  200 : 291.6   461.5
      200 x   40 x 1000 : 277.4   431.9
      200 x 1000 x   40 : 452.5   572.1
     1000 x   40 x  200 : 298.1   460.4     
     1000 x  200 x   40 : 460.5   583.8
      100 x  100 x  100 :  31.7    51.9
    2D-arrays, iterate rows-columns
    rows  x cols  : auto     manual   fake
      200 x 20000 :  123.5    106.1    113.2    
    20000 x   200 :  119.5    106.1    115.0    
    10000 x 10000 : 3080.25  2659.65  2835.1
    1D-arrays, iterate over columns
    cols   : auto  manual  fake
    500000 : 11.5  11.8    11.6
    3D-arrays, iterate pages-rows, operate on columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 :  83.9   23.3     62.9
       40 x 1000 x  200 :  89.6   31.9     69.0     
      200 x   40 x 1000 :  74.3   27.6     62.2
      200 x 1000 x   40 : 135.6   76.2    107.1
     1000 x   40 x  200 :  75.3   31.2     68.6
     1000 x  200 x   40 : 133.6   71.7    108.7     
      100 x  100 x  100 :  13.0    5.4      9.9
    VI's
    I attached the VI's I used for testing. "ND_add_random_number.vi" (where N is 1, 2 or 3) is where all the action happens, taking a selector with a method and an array with the N dimensions as input. It returns the result and time in milliseconds. Using "ND_add_random_number_automated_test.vi" I run this for a few different situations (auto/manual/fake-indexing, interchanging the dimensions). The VI's starting with "3D_locality_" are used for the locality tests. The VI's starting with "3D_norows_" are used for the iterations over pages and columns only.
    Attachments:
    3D_arrays_2.zip ‏222 KB

    Robert,
    the copy-thing is not specific for auto-indexing. It is common for all tunnels. A tunnel is first of all a unique data space.
    This sounds hard, but there is an optimization in the compiler trying to reduce the number of copies the VI will create. This optimization is called "in-placeness".
    The in-placeness algorithm checks, if the wire passing data to the is connected to anything else ("branch"). If there is no other connection then the tunnel, chance is high that the tunnel won't create an additional copy.
    Speaking of loops, tunnels always copies. The in-placeness algorithm cannot opt that out.
    You can do a small test to elaborate on this: Simply wire "0" (or anything less than the array sizy of the input array) to the 'N' terminal.......
    Norbert
    PS: Auto-indexing is perfect for a "by element" operation of analysis without modification of the element in the array. If you want to modify values, use shift registers and Replace Array Subset.
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Unable to plot 1-D array with a cluster of 2 elements on an XY graph

    I'm Unable to plot a 1-D array with a cluster of 2 elements on an XY graph. The data appears at the input to the graph but nothing is plotted. I'm trying to plot a line connecting each point generated.
    Solved!
    Go to Solution.
    Attachments:
    TEST11.vi ‏13 KB

    Chuck,
    0. Do not post VIs with infinite loops! Change the True constant to a control.  One of the regular participants on these Forums has commented that using the Abort button to stop a VI is like using a tree to stop a car.  It works, but may have undesired consequences!
    1. Use a shift register on the For loop also.
    2. Inserting into an empty array leaves you with an empty array.  Initialize the array outside the loop to a size greater or equal to the maximum size you will be using.  Then use Replace Array Subest inside the loop.
    3. Just make an array of the cluster of points.  No need for the extra cluster.
    Lynn
    Attachments:
    TEST11.2.vi ‏11 KB

  • Populating a javascript array with datatable data

    I want to populate a javascript array with datatable data.
    How do I do this?
    I want the javascript array to be populated as the datatable is displayed.
    Doing this way doesn't work.
    <h:dataTable value="#{pmManager.profiles}" var="pmProfile" binding="#{pmManagerUiBean.uiTable}" ">
    <script>
    allProfilenames[index]='#{pmProfile.profileName}';
              alert("index ="+index);
              alert("...1"+allProfilenames[0]);
              alert("...2"+allProfileRes[0]);
              index++;
    </script>
    <h:dataTable>

    In Javascript do something like this:
    document.getElementById('form1:dec_param');
    where form1:dec_param is the id of the component on the page source (html)

Maybe you are looking for