A newbie with another question

Sorry for my ignorance, but I'm just in my first semester of programming. I'm confused as to what syntax is required when you use classes with a couple of methods inside? In one of my programs, our professor provided us with a file called Zipfstatistics.class and though he told us that the two methods are Slope(wordFrequency) and RSquared(wordFrequency), I can't seem to compile them properly. I've tried compiling them as text.Slope(wordFrequency) and text.RSquared(wordFrequency) respectively and both produce compiler errors. Does anyone have a solution to this problem?
Thanks again people.

Here is the code.
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Array;
import java.util.Random;
import java.util.regex.Pattern;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.table.DefaultTableModel;
* @author jobuck
public class WordFrequency {
     private JTextArea ta = null;
     private JFrame frame = null;
     private JScrollPane tableScrollpane = null;
     private JScrollPane resultScrollpane = null;
     private JTable table = null;
     private final int MAX_LENGTH = 12;
     private final int MAX_WORD = 1000;
     private final int WORD_PER_LINE = 25;
     private Random random = new Random();
     private final char WORD_SEPARATOR = ' ';
     private Pattern pattern = Pattern.compile("\\p{Alnum}");
     private TableModel tableModel = null;
     public WordFrequency() {
          tableModel = new TableModel();
          table = new JTable(tableModel);
          frame = new JFrame("Word Frequency");
          JTextArea result = tableModel.getTextAreaFrenquency();
          tableScrollpane = new JScrollPane(table);
          resultScrollpane = new JScrollPane(result);
          Box box = new Box(BoxLayout.Y_AXIS);
          box.add(resultScrollpane);
          box.add(tableScrollpane);
          frame.addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent evt) {
                    System.exit(0);
          frame.getContentPane().add(box);
          frame.setSize(800, 400);
          frame.setVisible(true);
     public static void main(String[] args) {
          WordFrequency df = new WordFrequency();
     private class TableModel extends DefaultTableModel {
          //Even if we don't need to compute words, as we
          //only have interest on there length, let's do it anyway
          private final char[] validChars =
               'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
               'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
               'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
               'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
               'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
               'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
               'w', 'x', 'y', 'z', '0', '1', '2', '3',
               '4', '5', '6', '7', '8', '9', ';', '.'
          private String[][] values =
               (String[][]) Array.newInstance(
                    String.class,
                    new int[] { MAX_WORD / WORD_PER_LINE + 1, WORD_PER_LINE });
          private int maxWordLength = 0;
          private int[] frequencyLength =
               (int[]) Array.newInstance(int.class, new int[] { MAX_LENGTH + 1 });
          public TableModel() {
               generateText();
          private void generateText() {
               int col = 0;
               int row = 0;
               int wordLength = 0;
               char wordChar;
               for (int i = 0; i < MAX_WORD; i++) {
                    StringBuffer text = new StringBuffer();
                    wordLength = random.nextInt(MAX_LENGTH + 1);
                    for (int j = 0; j < wordLength; j++) {
                         wordChar =
                              (char) validChars[random.nextInt(validChars.length)];
                         text.append(wordChar);
                    row = i % WORD_PER_LINE;
                    col = (i > 0 && row == 0) ? col + 1 : col;
                    values[col][row] = text.toString();
                    frequencyLength[wordLength] += 1;
                    maxWordLength =
                         (maxWordLength < frequencyLength[wordLength])
                              ? frequencyLength[wordLength]
                              : maxWordLength;
               for (int i = 0; i < MAX_LENGTH + 1; i++)
                    System.out.println(
                         "frequency(" + i + ") : " + frequencyLength);
          private String getResult() {
               int[] frequency = getFrequency();
               StringBuffer frequencyGraph = new StringBuffer();
               System.out.println("getMaxWordLength()=" + getMaxWordLength());
               boolean isDC = false; //Just show the shape, removing
               boolean exit = false; //Just show the shape
               int dc = 0;
               for (int i = getMaxWordLength();(i >= 0) & !exit; i--) {
                    exit = true;
                    //Vertical axis
                    //TODO: adapt to frequency length to avoid banana axis
                    frequencyGraph.append("\n"+i+" + ");
                    for (int j = 0; j < MAX_LENGTH + 1; j++) {
                         isDC = (frequency[j] >= i);
                         exit &= isDC;
                         frequencyGraph.append((!isDC) ? " " : " * ");
                    dc = (exit)?i:0;
               frequencyGraph.append("\n");
               String space = "";
               //Space starting the x axis
               for (int i = 0;i<String.valueOf(dc).length()+3;i++)
                    space+=" ";               
               frequencyGraph.append(space.substring(2));
               //Horizontal axis
               for (int j = 0; j < MAX_LENGTH + 1; j++) {
                    frequencyGraph.append("+++");
               frequencyGraph.append("++");
               //Frequency
               frequencyGraph.append("\n");
               for (int j = 0; j < MAX_LENGTH + 1; j++) {
                    frequencyGraph.append( (j==0)?space +" " + j + " ": ((j<10)?" " + j + " ": " "+j) );
               return frequencyGraph.toString();
          public JTextArea getTextAreaFrenquency() {
               JTextArea ta = new JTextArea(getResult());
               ta.setFont(new Font("Monospaced",Font.PLAIN,10));
               return ta;
          private int getMaxWordLength() {
               return maxWordLength;
          public String[][] getValues() {
               return values;
          public int[] getFrequency() {
               return frequencyLength;
          public int getRowCount() {
               return MAX_WORD / WORD_PER_LINE + 1;
          public int getColumnCount() {
               return WORD_PER_LINE;
          public String getColumnName(int column) {
               return column + "";
          public boolean isCellEditable(int rowIndex, int columnIndex) {
               return true;
          public Object getValueAt(int row, int column) {
               return values[row][column];
          public void setValueAt(Object value, int row, int column) {
               values[row][column] = (String) value;

Similar Messages

  • Apple newbie with dummy question

    I have a question about my 3 day old Core Duo. I'm connecting just fine and love my machine, but before I go paying bills/banking/etc online, I want to make sure my connection is secure. I'm connecting wirelessly via a Lynksis WRT54G router. The very first time I turned this bad-boy on, it asked for a password to the network, but hasn't since. I'm afraid I may have "keychained" the password or opened the network to everyone or something. Is there a way to check? I chatted with an agent, and they said since it was a third party thing (Lynksis), they couldn't answer. All I want to make sure of, is that my connection is secure with either WPA/WEP. I don't even know what that means, I just know it makes it secure! Again - first time Apple user (unless you count my Dad's IIC when I was 8) - so please assume I'm a dummy when you reply!
    Thanks,
    Matt

    Hello Matt
    Goto your router's config at http://192.168.1.1 the default user is admin and the password is admin
    goto the wireless tab then wireless security. Make sure your using WPA-PSK and NOT WEP.
    WEP is easily cracked WPA is a lot more secure.
    The first time you connect to a wireless network you do have the option to add the password to the keychain, this is normal and does not have any security problems.
    To check to see if you had added your wirless network password to your keychain open up the keychain Access found in /Applications/Utilities
    You can then see a list of all the keychain entries you may see your wireless network listed in there.

  • Newbie with LOM Questions

    I recently setup our new Intel xServe, mainly for file and print services. I have no problems using or connecting to the LOM processors with the Server Monitor App. But my question is which LOM port should I be using to connect with Server Monitor? I can connect to both at the same time, and both give the same info. Is there a better one to use?
    Also, in Server Monitor it list the LOM processors IP in both the IP address and Name columns. I would like to be able to change so that it would list the servers name in the name column. Any ideas?
    Thanks for any reply's in advance.

    I can't answer No.1 but here are my views on 2 and 3.
    2. That is true at the moment, there are no Mac viruses or other malware out in the wild. This may change in the future, but for now you are quite safe. If you intend to install Bootcamp and Windows, then you will in the windows environment be exposed to all the windows viruses, etc.
    3. I very rarely shutdown my iMac, usually only if I go on holiday or need to reboot after a software install. I always use sleep even for longer than 8 hours.
    Ian

  • Complete Newbie with Organizing Question

    Please understand that I'm a complete Neophyte at Mac, and iPhoto. Please respond accordingly.
    I'm a Windows guy who has succumbed to the intrigue and mystery of the Mac. I've got the Intel Dual Core iMac with 250GB HDD and 1 GB RAM. I just got it less than a month ago, and I've managed to fill up the internal hard drive to the top. My largest HDD space is taken up by my photos. Before reading any documentation (Windows guys rarely read documentation) I "moved" my iPhoto Library from the "me" user directory/folder over to a "shared" directory/folder.
    Long story short, I now have multiple copies of photos, and the calendars and books we were beginning to work on have lost their pointers to the appropriate pictures.
    Here's the jist of my question. Can I just delete the entire iPhoto Library, and all the photos and then sort of start over from scratch? I still have all my originals on my PCs that are all home networked together.
    My apologies for my ignorance, and also if this is covered somewhere else in the discussion forum. I'm just a bit frustrated, as well as a bit inpatient to get it all fixed. Any assistance will be greatly appreciated. Thanks.
    Mike Macygin

    Mike,
    Delete your old library
    Under your account, open iPhoto
    A new library will be created
    Import your photos
    Close iPhoto
    Do a "get info" on the external drive to make sure it is formated for a Mac.
    If not, use Disk Utility, found in your Utilities folder to erase it and format it for a Mac. You can also partition the drive at this time. One partition you can use for your iPhoto Library folder and the other partition you can use for backups.
    Here is an Apple kb on moving the library to an external
    http://docs.info.apple.com/article.html?artnum=93037
    Take a look at my last post in these threads that have to do with trying to share a library.
    http://discussions.apple.com/message.jspa?messageID=2225214#2225214
    http://discussions.apple.com/message.jspa?messageID=2201779#2201779

  • Newbe with a question

    First, I would like to say Hello to all of the other forummers, as being a newbe.
    And as a newbe, I offcourse have a question....
    Will the new AMD 333fsb  series processors run on my KT3 mainboard, after obviously flashing the bios?
    Thanks in advance, David.
    Config: MSI kt3 ultra, xp1800, geforce 2ti, 512mb apacer ddr2700, 7200rpm maxtor and chello cable connection.

    I heard somewhere that the chipset will support it but I don't know if MSI will work to get this board to support it.

  • Potential Newbie with Synch Questions

    Hi,
    I am seriously considering purchasing a BB8120, but I have questions about how much information or data is synchronized when synchronizing with Outlook 2007. I would like to be able to synchronize my calendar and contacts, but can anyone please tell me HOW MUCH of each is synchronized? Is the synchronization true, in that when I look at my calendar on BB it will have the exact same information and features as my desktop, and when I look at my contacts on BB it will actually have name, phone, address, e-mail, etc?
    Thanks!
    Adelle

    I hope it works well or RIM wouldn't be selling them.
    Click here to Backup the data on your BlackBerry Device! It's important, and FREE!
    Click "Accept as Solution" if your problem is solved. To give thanks, click thumbs up
    Click to search the Knowledge Base at BTSC and click to Read The Fabulous Manuals
    BESAdmin's, please make a signature with your BES environment info.
    SIM Free BlackBerry Unlocking FAQ
    Follow me on Twitter @knottyrope
    Want to thank me? Buy my KnottyRope App here
    BES 12 and BES 5.0.4 with Exchange 2010 and SQL 2012 Hyper V

  • Newbe with iWeb question

    Hello all new here and no computer expert by all means so please bare with me.
    Trying to create a web page for a for a friend
    What i would like to do is have a bio section for crew members. What would be the best way to do this??????
    I would like to have one heading that says (The Crew) and then sub headings with each persons bio.
    The only way i see how to do this is to create multiple (about me's) this would be fine but i would like them all under one heading.
    Thanks for you help

    Rather than use a template you can start with a Blank page in whatever theme you are using.
    Drag photos onto the page from the Finder or iPhoto and resize then to suit.
    Insert text boxes for headings, sub headings and content. Make sure you use a web safe font.....
    http://www.iwebformusicians.com/WebMusic/FontsandColors.htm
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • MOVED: Newbie With A Question

    This topic has been moved to Graphics Cards.
    https://forum-en.msi.com/index.php?topic=252068.0

    This is interesting, I believe I found what is an ASCII->Unicode file converter for OSX. It is a command-line tool, so you would need to know how to use terminal.
    Go to this page and take a look:
    http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=TECkitDownloads
    The installer is:
    TECkit version 2.2.1 for Mac OS X
    Jonathan Kew, 2006-09-19
    Download "TECkitinstaller2.2.1.tar.gz
    I downloaded it and installed it, the command to launch it is:
    /usr/local/bin/txtconv
    which returns an instruction page. This looks like a document converter, not a filename converter.
    I don't have any non-english files here so I can't test it, but maybe someone who knows more about command tools can help you more, like the UNIX forum on these boards.
    PS:
    I did tun the command on a test file like this:
    /usr/local/bin/txtconv -i ~/testIN.txt -o ~/testOUT.txt
    and it did create a new output file but no translated characters. If you would send a few files to my email address I'll mess with it for you.
    See my profile for that address.

  • Back with another question

    Hello all,
    I've created a custom table by using a PL/SQL anonymous block as my report. However I have noticed that I no longer have the ability to sum my rows or columns and I can't export to Excel.
    I had to create my own table as I could not format it by simply using a PL/SQL or SQL report. So I opted for creating an HTML table.
    Does anyone know if it is possible to incorporate both a sum of rows and an export to excel using a PL/SQL anonymous block?
    Does anyone have any links to an example? Thank you!
    The code for my table is as follows(many might have already seen from previous posts).
    declare
    apps1 varchar2(75);
    noper varchar2(10) := '0.0';
    day date;
    day2 date;
    cursor c_apps is
    SELECT DISTINCT APPS
    FROM OUTAGE_1
    WHERE INSTR(':'||:P4_SYSTEMS||':',':'||APPS||':') > 0
    OR :P4_SYSTEMS LIKE '%-1%'
    AND NOTABLE = 'N' /*excluding notable events*/
    AND METRICS = 'Y' /*include outages where metrics is yes*/
    order by 1;
    cursor c_per (perAppId in varchar2)is
    SELECT dates_apps.day2, /*obtaining day from dates_apps temp table below*/
    dates_apps.apps,/*obtaining apps from dates_apps temp table below*/
    nvl(trunc(the_totals.percent,2),0)Percent /*obtaining percentages from the_totals*/
    FROM
    SELECT APPS,
    trunc(START_DATE)day2,
    SUM (TOTAL_HOURS)*100/TRUNC(((TO_DATE (:P4_END_DATE, 'MM/DD/YYYY') - TO_DATE(:P4_START_DATE, 'MM/DD/YYYY')+1)*24))percent
    FROM OUTAGE_1
    WHERE APPS = perAppId
    GROUP BY APPS,
    trunc(START_DATE))the_totals,
    /*end of temp table the_totals - obtaining apps and percentages*/
    SELECT the_app.apps,
    the_dates.day2
    FROM(
    SELECT DISTINCT APPS
    FROM OUTAGE_1
    WHERE APPS = perAppId)the_app,
    /*end of temp table the_app - obtaining distinct apps */
    SELECT TRUNC (TO_DATE (:P4_START_DATE, 'MM/DD/YYYY') + LEVEL - 1)day2
    FROM dual
    CONNECT BY LEVEL <=TRUNC (TO_DATE (:P4_END_DATE, 'MM/DD/YYYY'))
    - TRUNC (TO_DATE (:P4_START_DATE, 'MM/DD/YYYY')) +1 )the_dates
    /*end of temp table the_dates - looping through dates based on user input dates */
    )dates_apps
    /*end of dates_apps temp table*/
    WHERE dates_apps.apps = the_totals.apps(+)
    AND dates_apps.day2 = the_totals.day2(+)
    AND dates_apps.apps like '%'
    order by 1,2;
    begin
    htp.p('<table BORDER="1" CELLSPACING="0" CELLPADDING="0" WIDTH="100%">');
    htp.p('<tr BGCOLOR="#FF0000">');
    htp.p('<th>DAY</th>');
    for i in (SELECT TRUNC (TO_DATE (:P4_START_DATE, 'MM/DD/YYYY') + LEVEL - 1)day
         FROM dual
    CONNECT BY LEVEL <=TRUNC (TO_DATE (:P4_END_DATE, 'MM/DD/YYYY')) - TRUNC (TO_DATE (:P4_START_DATE, 'MM/DD/YYYY')) +1 )
    loop
    htp.p('<th>' ||i.day||'</th>');
    end loop;
    htp.p('</tr>');
    htp.p('<tr BGCOLOR="#FF0000">');
    for i in c_apps
    loop
    htp.p('<tr>');
    htp.p('<th>' ||i.apps||'</th>');
    for k in c_per (i.apps)
    loop
    htp.p('<th>' ||k.percent||'</th>');
    end loop;
    htp.p('</tr>');
    end loop;
    end;

    you are welcome
    Thanks
    Michael Altringer
    Altringer & Associates Inc
    Fine Wood Floors
    www.anainc.net
    612-940-8749
    Youngevity 90 for Life

  • Newbie with easy question

    I have a <SPAN class=GraySubTitleBoldund>Sound Blaster Audigy 2 ZS and want to hook up my Sony Handycam DCR-TRV260.
    <SPAN class=GraySubTitleBoldund>It appears the ieee394 on the Sound Blaster is a 6 pin.
    <SPAN class=GraySubTitleBoldund>Is that correct?
    <SPAN class=GraySubTitleBoldund>
    <SPAN class=GraySubTitleBoldund>Does anyone know what cable I need (or if one is available) to go directly from my camera to the Sound Blaster?
    <SPAN class=GraySubTitleBoldund>
    <SPAN class=GraySubTitleBoldund>I think the Sony i Link cable goes to a 4 pin ieee394 .. but I am not sure.
    <SPAN class=GraySubTitleBoldund>
    <SPAN class=GraySubTitleBoldund>Thanks for your help.
    <SPAN class=GraySubTitleBoldund>
    <SPAN class=GraySubTitleBoldund>

    I hope you are connecting to the Guest network, that's the reason whenever you open up the internet explorer it prompts you for the login information. make sure you are not connected to the Guest network.

  • Apple Airport newbie with some questions before purchasing - please help...

    Hello all,
    Please excuse my ignorance but despite looking through the relevant online manual I wish to check a couple of things before I purchase the Aiport Express (and then possibly regret it).
    I have a Windows XP laptop which connects to the internet through a wi-fi connection (access to the physical router is not available me) and I want to be able to play iTunes on my laptop through my hi-fi (wirelessly).
    Am I correct in thinking the Aiport Express will do this for me? If so is any extra equipment besides the necessary hi-fi to Airport express cable required?
    The Airport Express doesn't need to physically connect to the router does it? Or it doesn't need to become the router providing the wi-fi does it?
    How does 'AirTunes' factor into the setup and what is better about e.g. Aiport Extreme and why would you ever need an Airport card?
    I have no desire for using the Airport equipment as a router or home hub for printing etc. but just streaming iTunes to my hi-fi.
    Any help/clarification would be most appreciated. Many thanks in advance,
    Daniel

    djsuk43, Welcome to the discussion area!
    Am I correct in thinking the Aiport Express will do this for me?
    Yes
    The Airport Express doesn't need to physically connect to the router does it? Or it doesn't need to become the router providing the wi-fi does it?
    No and no.
    How does 'AirTunes' factor into the setup...
    It is simply the term Apple uses for streaming music via iTunes through the AirPort Express (AX).
    ...what is better about e.g. Aiport Extreme...
    The AirPort Extreme base station (AEBS) does not have an audio out port therefore you can't use it to stream music.
    The AEBS however does support Ethernet clients, multiple USB printer and multiple USB hard drives.
    ...and why would you ever need an Airport card?
    If you have an older Mac without built-in wireless you would add the appropriate AirPort card to give it wireless ability.

  • Brand Newb with a Question

    I have my background image on a stage, and all I want to do
    is have a cut out smaller image of a figure floating around on the
    background. However, when I import the figure from PS it has it's
    annoying white background attached, even when I paste to a new
    transparent BG document in PS. How do I get the figure ONLY into
    the stage/background area?
    Thank you for your help.
    Crick

    Export the file from PS as a transparent PNG file. Once
    imported in Flash the BG will be transparent. OK, try it ASAP
    ;)

  • Yes, I'm back with another question.

    Hi again. I have to tell you, first, that my site is coming along quite well. However, I am having some difficulty in figuring out how to get a graphic to repeat itself, (tile) within a certain area. I am sure there is a tutorial, somewhere, that tells how to do this. If someone could steer me in the right direction I will be extremely grateful.
    Sue

    you are welcome
    Thanks
    Michael Altringer
    Altringer & Associates Inc
    Fine Wood Floors
    www.anainc.net
    612-940-8749
    Youngevity 90 for Life

  • Another question - I'm sorry!

    I'm sorry to bother you guys with another question. =p Just a quickie- How exactly do I get a movie from a DVD onto my computer after putting it in the drive? This is probably another stupid question, haha. ^_^; But I honestly haven't a clue.
    THANK YOU in advance!! =)

    It may be a quick question... but there's certainly no quick answer to it.
    The topic of DVD ---> iPod has been covered thoroughly in these forums already. There's literally hundreds of topics which answer your question for you.
    I would suggest that you search through the forums to find your answer, rather than start a whole new topic with duplicate information.

  • Thanks all for the great advice.  Another question.  If I use Entourage on my desktop Mac to access an email address I use on there, is it possible to be able to access my email on that same email address on my iPad either with or without Entourage?

    Thanks all for the great advice.  Another question.  If I use Entourage on my Mac desktop to access my mail using an email address I have on there, is it possible to access my emails on that same email address on my iPad, either with or without using Entourage.  Is there an Entourage app, or something I could use?  Thanks...

    Simply add the email account to Mail, no need for Entourage.
    One word of warning, though, iPads tend to become community property (meaning anyone who uses your iPad can access your email). That is why I have zero email accounts on my iPad.
    I use Entourage on my desktop as well, so going back and forth between Entourage and Mail (whether on your iPad or iPhone) is no problem.

Maybe you are looking for

  • Regarding Invoice Detail SMS to customer through ABAP program

    Hi  All ,                How can i send details of invoice ( invoice number,quantity,amount,total ledger balance of customer)  through SMS to customer with ABAP application program. please provide some sample code for this . Thanks & Regards shailesh

  • How to operate Ok and Update Button Simultaneously in SAP B1

    Hi All, I have placed a button in screen painter. I have given unique ID as 1. ie. It takes Caption as OK and on click of that Button Caption is changed to Update. I want to update the database on click of Update. How do I do this? Regards

  • Using Trex for Vendor Search in SRM

    Experts,    Please let me know if you used TREX to optimize the vendor search in SRM 7.0, ECC 6.0 EP4.    Please let me know any tips or suggestions regarding the implementation. Thanks in advance Regards, Scott

  • TOC and text flow bug?

    I have a TOC that spans about 5 pages (or should).  I've created the TOC and shift click insert it, it then place 2 1/2 pages (about 50% of the total) and then a preflight error is displayed regarding overflow text. Clicking it indicates the problem

  • Installing SAP ECC 6.0

    Dear Gurus, Is there any one who would install ECC 6.0 on my system? Or could you refer name and contact number of the person to whom i could get in touch with? Your prompt reply appreciated. Thanks, Sejal