Java tutor help for trade???
Results 1 to 6 of 6

Thread: Java tutor help for trade???

  1. #1

    Default Java tutor help for trade???

    I will trade mentor inspiration for help or a painted mini just make me a deal....but I really need help with my JAVA class...
    Is there anyone out there that programs I have only 2 weeks left of class and it is kicking my ass. I make huge efforts but I get stuck and could use a soft boot please.

    For example... right now it is how to handle double ints in a [10][10] array and count the digits occurrences in the 100 random generated number matrix. putty for someone who knows but the count loop with the ints is kicking my butt. I have looked all over the net and will continue and my teacher is not responding.
    If anyone has a few bits of time it would be appriciated and favor returned in kind.
    Winter is Coming...

    http://tabstudio.com

  2. #2

    Default

    Alright...

    What do you mean with "double ints" Are you storing double numbers, oder int number in your array? Are they primitive or the generated classes? That means how is your Array definied?

    with

    int [][]
    Integer[][]
    double[][] or
    Double[][]

    After this, what dou really want to count?

    Eg:
    10, 20, 30
    40, 50, 60,
    20, 22, 25

    Occurences:
    0 : seven times
    1 : once
    2 : five times
    3 : once

    and so on?

    Greetings, Taggi
    How do you know, that Taggi has been assimilated to borg: "Rezitanz fiutail ist."

    Sorry for violating the english language.


    Please rate my comments, even if there is critism in it, as a personal point of view. I do not have the absolute truth in minature painting and every word said by me is only a suggestion, that may be thought over or simple ignored. So, happy painting!


    And my own Dragons:


  3. #3

    Default

    It is numbers 1-9 but I used the double matrix so they would align better,that was my first mistake.
    Yes also I must count how many ones,twos etc occur in the 100 numbers generated and return the information under the matrix


    I have this
    /*
    * Tracy Brady
    */
    package countdigits;

    public class CountDigits {

    public static void main(String[] args){

    int[ ][ ] matrix = new int[10][10];



    //random numbers * 100
    for (int row = 0; row < matrix.length; row++){
    for (int column = 0;column < matrix[row].length; column++){
    matrix[row][column] = (int)(Math.random() * 10);
    }
    }
    //print array
    for (int row = 0; row < matrix.length; row++){
    for(int column = 0; column < matrix[row].length; column++){
    System.out.print(matrix[row][column] + " ");
    }
    System.out.println();
    }

    Now I need to count the number of times each integer shows up and print out the final sum.

    I know I need a loop to do it but the brackets are screwing me up
    I have tried ...


    for (int i =0; i< matrix.length;i++) {
    if ( i == 2) {
    int counterj = i;

    System.out.print("sh*t" + counterj);

    I was frustrated I have tried
    these approaches also //count array
    //
    // for (int j =0; j < matrix; j++){
    // System.out.println(j);
    // }
    //numberCounts(matrix);
    //displaycounts(matrix);


    // public static void numberCounts(int[][] num){
    // //array of teh
    // int[] []counts = new int[10][10];
    // for (int i = 0; i < num.length; i++){
    // System.out.print(counts + "fu**");
    // }
    //
    //
    // }
    //
    // public static void displaycounts(int [][] counts){
    // for (int i = 0; i < counts.length;i++){
    // System.out.print(counts + "sh** ");
    //
    // if ( i +1<0) {
    // System.out.print(counts + "f** ");
    // }
    //
    // else {
    // System.out.print(counts + "f** ");
    // }
    // }




    // public static int countNumbers(int[][] arr, int numToFind){
    // int countnum=0;
    // for (int i = 0; i < arr.length; i++) {
    // if (arr[i][i] == numToFind) {
    // countnum++;
    // }
    // }
    // return countnum;
    //
    // }
    // }

    // system.out.println(counts[i] + "" + (int)(int+ 1));
    // else
    // system.out.print(counts[i][i] + " " + (int) (i + 10)+ "");
    // }
    //
    // }
    // public static int find(int[] arr, int numToFind) {
    // int occurence=0;
    // for (int i = 0; i < arr.length; i++) {
    // if (arr[i] == numToFind)
    // occurence++;
    // return occurence;

    I asked my teacher for help...and I sent him this but I forgot to star out the profanities...I am thinking I will not get a quick response even though I apologized for the slip up. I am so frustrated...name your price I have 4 or five chapters more to go and it is not getting any easier.
    If we could trade I would be thankful for the help.I have worked at least 18 hours on this silly problem it is not the lack of effort. Thank you for your interest
    Last edited by TAB Studio; 02-11-2010 at 11:51 AM. Reason: well...
    Winter is Coming...

    http://tabstudio.com

  4. #4

    Default

    Ok... i have got it, what you want to do.

    For double numbers you can use:
    Code:
    import java.util.Random;
    
    public class digitis {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            
            double [][] randomNumbers = new double[10][10]; // preinitialised with 0
            int [] digitCounter = new int [10]; // preinitialised with 0
            
            Random generator = new Random();
            
            // int the random numbers in a range of 0 to 100
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j <10; j++)
                {
                    randomNumbers[i][j] = generator.nextDouble()*100;
                }
            }
            
            // for each row do
            for (int i = 0; i < 10; i++)
            {
                // for each number in row do
                for (int j = 0; j <10; j++)
                {
                    // parse to String
                    String dummy = ""+randomNumbers[i][j];
                    // delete all .
                    dummy = dummy.replace('.','\u0020');
                    // delete all ,
                    dummy = dummy.replace(',','\u0020');
                    // delete all -
                    dummy = dummy.replace('-','\u0020');
                    
                    // for each digit in dummy do
                    for (int k = 0; k < dummy.length(); k++)
                    {
                        if (!dummy.substring(k, k+1).equals(" "))
                        {
                            // integer of char:
                            int intDummy = Integer.parseInt(dummy.substring(k, k+1));
                            // rise counter of this digit
                            digitCounter[intDummy]++;
                        }
                    }
                    
                }
            }
            
            // OutPut:
            for (int i = 0; i < 10; i++)
            {
                System.out.println("Occurences of "+i+" : "+ digitCounter[i]);
            }
            
        }
    
    }
    Output like:
    Occurences of 0 : 135
    Occurences of 1 : 162
    Occurences of 2 : 193
    Occurences of 3 : 174
    Occurences of 4 : 160
    Occurences of 5 : 167
    Occurences of 6 : 138
    Occurences of 7 : 161
    Occurences of 8 : 156
    Occurences of 9 : 171
    For integer number from 0 to 10 it is shorter:
    Code:
    import java.util.Random;
    
    public class digitis {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            
            int [][] randomNumbers = new int[10][10]; // preinitialised with 0
            int [] digitCounter = new int [10]; // preinitialised with 0
            
            Random generator = new Random();
            
            // int the random numbers in a range of 0 to 100
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j <10; j++)
                {
                    randomNumbers[i][j] =(int)(generator.nextDouble()*10);
                }
            }
            
            // for each row do
            for (int i = 0; i < 10; i++)
            {
                // for each number in row do
                for (int j = 0; j <10; j++)
                {
                    digitCounter[randomNumbers[i][j]]++;
                }
            }
            
            // OutPut:
            for (int i = 0; i < 10; i++)
            {
                System.out.println("Occurences of "+i+" : "+ digitCounter[i]);
            }
            
        }
    
    }
    Sample output:
    Code:
    Occurences of 0 : 11
    Occurences of 1 : 13
    Occurences of 2 : 9
    Occurences of 3 : 9
    Occurences of 4 : 8
    Occurences of 5 : 4
    Occurences of 6 : 15
    Occurences of 7 : 16
    Occurences of 8 : 11
    Occurences of 9 : 4
    Have fun!

    Greetings, Taggi
    How do you know, that Taggi has been assimilated to borg: "Rezitanz fiutail ist."

    Sorry for violating the english language.


    Please rate my comments, even if there is critism in it, as a personal point of view. I do not have the absolute truth in minature painting and every word said by me is only a suggestion, that may be thought over or simple ignored. So, happy painting!


    And my own Dragons:


  5. #5

    Default

    Dear fuzzy monkey totem...

    It's like work is haunting me even here. But alas, I'm no expert in JAVA. Sorry Tabby.
    Nosus decipio - We Cheat

  6. #6

    Default

    Tagamoga thank you so very much! Your kindness can not go unacknowledged.
    Sorry to haunt you IdofEntity but I oh so needed help. I am on to the next chapter because of her!
    Winter is Coming...

    http://tabstudio.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Privacy Policy  |   Terms and Conditions  |   Contact Us  |   The Legion


Copyright © 2001-2018 CMON Inc.

-->