Could use a little help with my program!

Okay, So I have this assignment right, and I'm supposed to read a file full of numbers into an array and then print out the 5 most frequently appearing numbers in the file.The file is arranged so that for each line in the file there are 5 different numbers separated by semicolons. So I've been working on the code and I cant for the life of me figure out how to get the array to work properly, ill post the code I have so far, the one line of code that is causing me problems is in line 21 of the program and it is stuff[i][j] = data.nextInt(); For some reason eclipse freaks out about it here is the rest of the program........ I'm not asking anyone to do the program for me I just need some help on what I am doing wrong.
Thanks,
Tony
public class Nums {
public static void main(String[]args)throws IOException
int[][] stuff = new int [300] [5];
Scanner data = new Scanner(new File(args[0]));
String X = data.nextLine();
for (int i=0;i<300;i++){
for (int j=0;j<5;j++){
stuff[i][j] = data.nextInt();
System.out.println(X);
for (int i=0;i<300;i++){
for (int j=0;j<5;j++){
System.out.print(stuff[i][j]+"\t");
System.out.println();
}

You're not reading in int's.... your reading text seperated by semicolons, so why not read the line in and then use String.split(";") on it? That will give you an array of strings indexed from 0 to 4 (if there are 5) and you can then convert them to int's and do what ever you need to do with them.
String myString = data.nextLine();
Stirng[] s = myString.split(";");
for(int i=0; i<s.length; i++){
  //your code goes here
}

Similar Messages

  • Little Help with my program..

    Ok... I am not completely finished with the program but I need to figure out something before I move on. This program is reading in information from a file. The thing I am having a problem with is how I can get it to add the GPA for each group of people, instead of adding the GPA for everyone in the file!! This program is basically reading in, the "groups living group", the name of each student, and their GPA. If you run my program, you will see a printout of "GPA sum in group" and GPA sum overall, I figured out how to get the sum overall for all the groups, but I cant figure out how to get the sum for each individual group! I hope this makes sense!!! If you need more clarification just ask!!! Thanks in advance! Also, I have compiled the program already and it runs just fine..!
    I will give you the information from the file being read in. Here it is
    Kappa Alpha Tau Sorority
    Hollander 3.347
    LaFarge 1.110
    EndOfGroup
    Taylor 2C Dormitory Section
    Rapoport 2.2956
    Smith 3.87
    Scarl 3.48
    Granville 2.946
    EndOfGroup
    Richards 4B Dormitory Section
    Horstmann 2.769
    Cole 3.47
    Barney 2.23
    EndOfGroup
    Here is my code!!!!
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class GPA
    public static void main(String[] args)
    final String SENTINEL = "EndOfGroup";
    final double MAX_GPA = 4.0;
    final Double MIN_GPA = 0.0;
    final boolean DEBUG = true;
    String livingG, studentName, stuName, wrongFormat;
    double gpa = 0.0, gpaSum = 0.0, dVal = 0.0, maxGpa = 0.0,
    avgGpa = 0.0, minGpa = 0.0, overMax = 0.0, overMin = 0.0,
    dMin = 0.0, dMax = 0.0;
    int counter = 0, grpNum = 0, totNum = 0;
    DecimalFormat form = new DecimalFormat("0.00%");
    Scanner scan = new Scanner(System.in);
    while(scan.hasNext())
    livingG = scan.nextLine();
    System.out.println("Living Group: " + livingG);
    stuName = scan.next();
    grpNum = 0;
    while(!stuName.equals(SENTINEL))
    if(!scan.hasNextDouble())
    wrongFormat = scan.next();
    System.out.println("ERROR: USER INPUT NOT IN PROPER " +
    "FORMAT " + wrongFormat);
    else
    gpa = scan.nextDouble();
    System.out.println(" Student: " + stuName + " GPA = " +
    gpa);
    if(DEBUG == true)
    grpNum++;
    counter++;
    gpaSum = gpaSum + gpa;
    totNum++;
    System.out.println("DEBUG:" + "\n" + " Number in group = " +
    grpNum + " GPA sum in group = " + gpa + "\n" + " Total " +
    "number = " + totNum + " GPA sum overall = " + gpaSum + "\n" +
    " Minimum GPA in group = " + dMin + " Maximum GPA " +
    "in group = " + MAX_GPA + "\n" + " Overall minimum GPA = " +
    overMin + " Overall maximum GPA = " + overMax);
    System.out.println();
    stuName = scan.next();
    else
    stuName = scan.next();
    System.out.println("Average GPA for this group = " + gpaSum / counter);
    System.out.println("Minimum GPA for this group = " + minGpa);
    System.out.println("Maximum GPA for this group = " + maxGpa);
    System.out.println();
    livingG = scan.nextLine();
    }

    Oh, Ok I see the code tag thing now!!! I will use now. Any other input to my question?
    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class GPA
       public static void main(String[] args)
          final String SENTINEL = "EndOfGroup";
          final double MAX_GPA = 4.0;
          final Double MIN_GPA = 0.0;
          final boolean DEBUG = true;
          String livingG, studentName, stuName, wrongFormat;
          double gpa = 0.0, gpaSum = 0.0, dVal = 0.0, maxGpa = 0.0,
          avgGpa = 0.0, minGpa = 0.0, overMax = 0.0, overMin = 0.0,
          dMin = 0.0, dMax = 0.0;
          int counter = 0, grpNum = 0, totNum = 0;
          DecimalFormat form = new DecimalFormat("0.00%");
          Scanner scan = new Scanner(System.in);
          while(scan.hasNext())
             livingG = scan.nextLine();
             System.out.println("Living Group: " + livingG);
             stuName = scan.next();
              grpNum = 0;
             while(!stuName.equals(SENTINEL))
                if(!scan.hasNextDouble())
                wrongFormat = scan.next();
                System.out.println("ERROR: USER INPUT NOT IN PROPER " +
                "FORMAT " + wrongFormat);
                else
                gpa = scan.nextDouble();
                System.out.println("   Student:  " + stuName + "     GPA = " +
                gpa);
                if(DEBUG == true)
                grpNum++;
                counter++;
                gpaSum = gpaSum + gpa;
                totNum++;
                System.out.println("DEBUG:" + "\n" + "   Number in group = " +
                grpNum + "   GPA sum in group = " + gpa + "\n" + "   Total " +
                "number = " + totNum + "   GPA sum overall = " + gpaSum + "\n" +
                 "   Minimum GPA in group = " + dMin + "   Maximum GPA " +
                "in group = " + MAX_GPA + "\n" + "   Overall minimum GPA = " +
                overMin + "   Overall maximum GPA = " + overMax);
                System.out.println();
                stuName = scan.next();
                else
                stuName = scan.next();
          System.out.println("Average GPA for this group = " + gpaSum /    counter);
          System.out.println("Minimum GPA for this group = " + minGpa);
          System.out.println("Maximum GPA for this group = " + maxGpa);
          System.out.println();
          livingG = scan.nextLine();
    }

  • Need a little help with a program...

    hi,
    I have an assignment for class where we have to write a recursive program using a method that calculates Hermite Polynimials.
    the math-like definition looks like this:
    Hn(x)=
    n<=0 : 1
    n==1: 2x
    n>=2 : 2xH(n-1)(x)-2(n-1)H(n-2)x
    (but the H(2-1) and H(n-2) are subscripts...)
    well, the program is supposed to accept arguments for n and x from the command line.
    but I'm having problems..
    here's the code that I have:
    class HermitePoly
    public int Herm( int N, int X )
    if ( N<=0 )
    return 1;
    else if ( N==1 )
    return 2*X;
    else
    return (2*X)*Herm(N-1)*(X) - (2*(N - 1)*Herm(N-2)*(X));
    public static void main ( String[] args)
    int argument = Integer.parseInt( args[0] );
    HermitePoly f = new HermitePoly();
    int result = f.Herm( argument, argument);
    System.out.println("Herm(" + argument + ") is " + result );
    the errors that it's giving me say:
    HermitePoly.java:12: Herm(int, int) in HermitePoly cannot be applied to (int) return(2*X)*Herm*(N-1)*(X)- (2*(N-1)*Herm(N-2)*(X));
    both errors say the same thing, but the first one, the pointer points to the first Herm() call, and in the second error, it points to the second Herm() call in the equation. I know what it means, but I don't know how to fix it.
    any help would be greatly appreciated!!

    Parentheses are your friend
    return ((2*X)*(Herm(N-1, X)*(X)) - (2*(N-1)*(Herm(N-2, X)*(X))Also, you need to pass X back into your Herm function again, since it takes two parameters.

  • Hello, need a little help with this program

    i have this program and i cant see whats wrong with it. but when i run it the error "Exception in thread 'main' java.lang.NoSuchMethodError: main"
    anyone know what wrong?
    class Assignment2
       public final
       void main( String[] argv )
           Script sc = new Script ("Assignment2.txt");
           KeyboardReader kb = new KeyboardReader();
         System.out.println( "Enter Time In 24hr Mode (use -999 to quit) : " );
         int time = kb.getInt();
         if (time == -999) {     System.out.println( "EXIT" );}
         System.out.println( "" );
         System.out.println( "Enter The Distance Of The Call (use -999 to quit) : " );
         int distance = kb.getInt();
         if (distance == -999) {     System.out.println( "EXIT" );}
           System.out.println( "" );
         System.out.println( "Enter Length Of Call In Minutes (use -999 to quit) : " );
         double length = kb.getDouble();
         if (length == -999) {System.out.println( "EXIT" );}     
           System.out.println( "" );
           Calculation (time, distance, length);
       }// end main
    public void Calculation (int time, int distance, double length)
              while (time != -999 || distance != -999 || length != -999)
                   if (700 <= time && time <= 1900 && distance <= 100)
                          System.out.println( "Cost of call is $0.60 per minute" );
                          double cost = 0.60 * length;
                          System.out.println( "That call will cost $ " + cost );
                     if  (700 <= time && time <= 1900 && distance > 100)
                          System.out.println( "Cost of call is $1.10 per minute" );
                          double cost = 1.10 * length;
                          System.out.println( "That call will cost $ " + cost );
                     if  (700 <= time && time <= 1900 && distance > 100)
                          System.out.println( "Cost of call is $1.10 per minute" );
                          double cost = 1.10 * length;
                          System.out.println( "That call will cost $ " + cost );
                System.out.println( "EXIT" );            
      }//end calculation
    }//end class
    //----------------------------------------------------------------------------------------------------

    i have this program and i cant see whats wrong with
    it. but when i run it the error "Exception in thread
    'main' java.lang.NoSuchMethodError: main"
    anyone know what wrong?When you get exceptions you also get a stack trace pointing you at the exact line where the exception occured in your code.

  • Help with Paint program.

    Hello. I am somewhat new to Java and I was recently assigned to do a simple paint program. I have had no trouble up until my class started getting into the graphical functions of Java. I need help with my program. I am supposed to start off with a program that draws lines and changes a minimum of 5 colors. I have the line function done but my color change boxes do not work and I am able to draw inside the box that is supposed to be reserved for color buttons. Here is my code so far:
    // Lab13110.java
    // The Lab13 program assignment is open ended.
    // There is no provided student version for starting, nor are there
    // any files with solutions for the different point versions.
    // Check the Lab assignment document for additional details.
    import java.applet.Applet;
    import java.awt.*;
    public class Lab13110 extends Applet
         int[] startX,startY,endX,endY;
         int currentStartX,currentStartY,currentEndX,currentEndY;
         int lineCount;
         Rectangle red, green, blue, yellow, black;
         int numColor;
         Image virtualMem;
         Graphics gBuffer;
         int rectheight,rectwidth;
         public void init()
              startX = new int[100];
              startY = new int[100];
              endX = new int[100];
              endY = new int[100];
              lineCount = 0;
              red = new Rectangle(50,100,25,25);
              green = new Rectangle(50,125,25,25);
              blue = new Rectangle(50,150,25,25);
              yellow = new Rectangle(25,112,25,25);
              black = new Rectangle(25,137,25,25);
              numColor = 0;
              virtualMem = createImage(100,600);
              gBuffer = virtualMem.getGraphics();
              gBuffer.drawRect(0,0,100,600);
         public void paint(Graphics g)
              for (int k = 0; k < lineCount; k++)
                   g.drawLine(startX[k],startY[k],endX[k],endY[k]);
              g.drawLine(currentStartX,currentStartY,currentEndX,currentEndY);
              g.setColor(Color.red);
              g.fillRect(50,100,25,25);
              g.setColor(Color.green);
              g.fillRect(50,125,25,25);
              g.setColor(Color.blue);
              g.fillRect(50,150,25,25);
              g.setColor(Color.yellow);
              g.fillRect(25,112,25,25);
              g.setColor(Color.black);
              g.fillRect(25,137,25,25);
              switch (numColor)
                   case 1:
                        g.setColor(Color.red);
                        break;
                   case 2:
                        g.setColor(Color.green);
                        break;
                   case 3:
                        g.setColor(Color.blue);
                        break;
                   case 4:
                        g.setColor(Color.yellow);
                        break;
                   case 5:
                        g.setColor(Color.black);
                        break;
                   case 6:
                        g.setColor(Color.black);
                        break;
              g.setColor(Color.black);
              g.drawRect(0,0,100,575);
         public boolean mouseDown(Event e, int x, int y)
              currentStartX = x;
              currentStartY = y;
              if(red.inside(x,y))
                   numColor = 1;
              else if(green.inside(x,y))
                   numColor = 2;
              else if(blue.inside(x,y))
                   numColor = 3;
              else if(yellow.inside(x,y))
                   numColor = 4;
              else if(black.inside(x,y))
                   numColor = 5;
              else
                   numColor = 6;
              repaint();
              return true;
         public boolean mouseDrag(Event e, int x, int y)
              int Rectheight = 500;
              int Rectwidth = 900;
              currentEndX = x;
              currentEndY = y;
              Rectangle window = new Rectangle(0,0,900,500);
              //if (window.inside(Rectheight,Rectwidth))
                   repaint();
              return true;
         public boolean mouseUp(Event e, int x, int y)
              int Rectheight = 500;
              int Rectwidth = 900;
              startX[lineCount] = currentStartX;
              startY[lineCount] = currentStartY;
              endX[lineCount] = x;
              endY[lineCount] = y;
              lineCount++;
              Rectangle window = new Rectangle(0,0,900,500);
              if (window.inside(Rectheight,Rectwidth))
                   repaint();
              return true;
         public void Rectangle(Graphics g, int x, int y)
              g.setColor(Color.white);
              Rectangle screen = new Rectangle(100,0,900,600);
    }If anyone could point me in the right direction of how to go about getting my buttons to work and fixing the button box, I would be greatly appreciative. I just need to get a little bit of advice and I think I should be good after I get this going.
    Thanks.

    This isn't in any way a complete solution, but I'm posting code for a mouse drag outliner. This may be preferable to how you are doing rectangles right now
    you are welcome to use and modify this code but please do not change the package and make sure that you tell your teacher where you got it from
    MouseDragOutliner.java
    package tjacobs.ui;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Stroke;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    * See the public static method addAMouseDragOutliner
    public class MouseDragOutliner extends MouseAdapter implements MouseMotionListener {
         public static final BasicStroke DASH_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 10.0f, new float[] {8, 8}, 0);
         private boolean mUseMove = false;
         private Point mStart;
         private Point mEnd;
         private Component mComponent;
         private MyRunnable mRunner= new MyRunnable();
         private ArrayList mListeners = new ArrayList(1);
         public MouseDragOutliner() {
              super();
         public MouseDragOutliner(boolean useMove) {
              this();
              mUseMove = useMove;
         public void mouseDragged(MouseEvent me) {
              doMouseDragged(me);
         public void mousePressed(MouseEvent me) {
              mStart = me.getPoint();
         public void mouseEntered(MouseEvent me) {
              mStart = me.getPoint();
         public void mouseReleased(MouseEvent me) {
              Iterator i = mListeners.iterator();
              Point end = me.getPoint();
              while (i.hasNext()) {
                   ((OutlineListener)i.next()).mouseDragEnded(mStart, end);
              //mStart = null;
         public void mouseMoved(MouseEvent me) {
              if (mUseMove) {
                   doMouseDragged(me);
         public     void addOutlineListener(OutlineListener ol) {
              mListeners.add(ol);
         public void removeOutlineListener(OutlineListener ol) {
              mListeners.remove(ol);
         private class MyRunnable implements Runnable {
              public void run() {
                   Graphics g = mComponent.getGraphics();
                   if (g == null) {
                        return;
                   Graphics2D g2 = (Graphics2D) g;
                   Stroke s = g2.getStroke();
                   g2.setStroke(DASH_STROKE);
                   int x = Math.min(mStart.x, mEnd.x);
                   int y = Math.min(mStart.y, mEnd.y);
                   int w = Math.abs(mEnd.x - mStart.x);
                   int h = Math.abs(mEnd.y - mStart.y);
                   g2.setXORMode(Color.WHITE);
                   g2.drawRect(x, y, w, h);
                   g2.setStroke(s);
         public void doMouseDragged(MouseEvent me) {
              mEnd = me.getPoint();
              if (mStart != null) {
                   mComponent = me.getComponent();
                   mComponent.repaint();
                   SwingUtilities.invokeLater(mRunner);
         public static MouseDragOutliner addAMouseDragOutliner(Component c) {
              MouseDragOutliner mdo = new MouseDragOutliner();
              c.addMouseListener(mdo);
              c.addMouseMotionListener(mdo);
              return mdo;
         public static interface OutlineListener {
              public void mouseDragEnded(Point start, Point finish);
         public static void main(String[] args) {
              JFrame f = new JFrame("MouseDragOutliner Test");
              Container c = f.getContentPane();
              JPanel p = new JPanel();
              //p.setBackground(Color.BLACK);
              c.add(p);
              addAMouseDragOutliner(p);
              f.setBounds(200, 200, 400, 400);
              f.addWindowListener(new WindowClosingActions.Exit());
              f.setVisible(true);
    }

  • Help with Recurrsion program

    I seem to be having a little problem with my program. In my main program, depending on which method comes first, the other methods wont work for example the way my main program is not, with occurance method before removeLetter method, the occurance method works fine, but my removeLetter meth won't remove the letter. But if i switch the two and have removeLetter first then it will remove the letter, but my occurance method will come back say the letter is not in the word even when it is...can someone help me? Thanx in advance...
    class CharacterRecurrance{
         private int i=0;
         private int occur=0;
         void inString(String s, char n){
              if(i<s.length()){
                   if(s.charAt(i)==n)
                        System.out.println("Yes, the letter" + " " + n + " " + "is present");
                   else{
                        i++;
                        inString(s,n);
              else System.out.println("No, the letter" + " " + n + " " + "is not present");
         void occurance(String s, char n){
              if(i < s.length()){
                   if(s.charAt(i)==n){
                        occur++;
                        i++;
                        occurance(s,n);
                   else{
                        i++;
                        occurance(s,n);
              else System.out.println("The letter" + " " + n + " " + "appears" + " " + occur + " " + "times");
         void removeLetter(String s, char n){
              if(i < s.length()){
                   if(s.charAt(i)==n){
                        s = s.replace(s.charAt(i),' ');
                        i++;
                        removeLetter(s,n);
                   else{
                        i++;
                        removeLetter(s,n);
              else System.out.println(s);
    class Program3_10{
         public static void main(String[] a) {
              CharacterRecurrance find = new CharacterRecurrance();
              String word = "mississippi";
              char letter = 's';
              find.inString(word, letter);
              System.out.println();
              find.occurance(word, letter);
              System.out.println();
              find.removeLetter(word, letter);
    }

    Or make it zero in the last step of each function. Like this-void occurance(String s, char n){
              if(i < s.length()){
                   if(s.charAt(i)==n){
                        occur++;
                        i++;
                        occurance(s,n);
                   else{
                        i++;
                        occurance(s,n);
              else{
                   System.out.println("The letter" + " " + n + " " + "appears" + " " + occur + " " + "times");
                   i=0; // reset to zero.
         }

  • This has happened on several computers. I can download using video download helper with on problems until I attempt to download "Dishonorable Disclosures" on Yo

    This has happened on several computers. I can download using video download helper with on problems until I attempt to download "Dishonorable Disclosures" on You Tube once a download attempt is made on that video download helper stops working for that video or any other video. Could this be a virus or malware? How do I fix download helper after this happens?

    Which movie do you mean?
    Try to clear the Google cookies.
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    *http://kb.mozillazine.org/Cookies
    You can also try to delete the webappsstore.sqlite file in the Firefox Profile Folder to clear the local storage.
    You can use this button to go to the Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Open Containing Folder
    *http://kb.mozillazine.org/Profile_folder_-_Firefox

  • Need a little Help with my new xfi titanium

    +Need a little Help with my new xfi titanium< A few questions here.
    st question? Im using opt out port on the xfi ti. card and using digital li've on a windows 7 64 bit system,? I would like to know why when i use 5. or 7. and i check to make sure each speakear is working the rear speakers wont sound off but the sr and sl will in replace of the rear speakers. I did a test tone on my sony amp and the speaker are wired correctly becasue the rear speakers and the surrond? left and right sound off when they suppose too. Also when i try to click on? the sl and sr in the sound blaster control panel they dont work but if i click on the rear speakers in the control panel the sl and sr sound off. Do anyone know how i can fix this? So i would like to know why my sl and sr act like rears when they are not?
    2nd question? How do i control the volume from my keyboard or from windows period when using opt out i was able to do so with my on board? sound max audio using spidf? Now i can only control the audio using the sony receiver.
    Thank you for any help..

    /Re: Need a little Help with my new xfi titanium? ?
    ZDragon wrote:
    I'm unsure about the first question. Do you even have a 7. system and receiver? If you just have 5., you should be able to remap the audio in the THX console.
    I do have a sony 7. reciever str de-995 its an older one but its only for my cpu. At first i didnt even have THX installed because it didnt come with the driver package for some reason until i downloaded the daniel_k support drivers and installed it. But it doesnt help in anyway.
    I have checked every where regarding the first question and alot of people are having problems getting sound out of there rear channels and the sound being re-mapped to the surround right and the surround left as if there rear left and rear right.
    I read somewhere that the daniel_k support drivers would fix this but it didnt for me and many others.
    For the second question i assumed it would be becasue of the spidf pass through and that my onboard sound card was inferior to the xfi titaniums. But i wasnt sure and i was hopeing that someone would have a solution for that problem because i miss controlling the volume with my keyboard.

  • Need a little help with syncing my iPod.

    I got a new macbook pro for cristmas and a few cds. After i tried to sync my ipod to itunes i put a symbol next to each song that i got from other cds saying that they were downloading but they werent. Also the cds i downloaded to my ipod for the first time didnt appear at all. Need help.

    /Re: Need a little Help with my new xfi titanium? ?
    ZDragon wrote:
    I'm unsure about the first question. Do you even have a 7. system and receiver? If you just have 5., you should be able to remap the audio in the THX console.
    I do have a sony 7. reciever str de-995 its an older one but its only for my cpu. At first i didnt even have THX installed because it didnt come with the driver package for some reason until i downloaded the daniel_k support drivers and installed it. But it doesnt help in anyway.
    I have checked every where regarding the first question and alot of people are having problems getting sound out of there rear channels and the sound being re-mapped to the surround right and the surround left as if there rear left and rear right.
    I read somewhere that the daniel_k support drivers would fix this but it didnt for me and many others.
    For the second question i assumed it would be becasue of the spidf pass through and that my onboard sound card was inferior to the xfi titaniums. But i wasnt sure and i was hopeing that someone would have a solution for that problem because i miss controlling the volume with my keyboard.

  • Hi there... I need a little help with buttons and their actions using flex builder 4.5

    I run a repo company and have zero experience in the developing applications and I could use some help from anybody that is willing to give it.... Here is a basic idea of what I need...  let's say there are 3 states... state 1 has a question that says "car you read this?" and a "yes" and a "no" button... when you select either answer, you go to slide 2.  Slide 2 with have a question like "Is the sky brown?" and a "yes" and a "no" button and when either button is selected, you are taken to Slide 3.  Slide 3 needs to be some sort of a text form that is created by the user selecting the buttons and the screen would say something like "yes, i can read this.  no, the sky is not brown", or "no, I can't read this.   yes, the sky is brown" .  I know how to get the buttons to take the user to the correct new slide, but I do not know how to get the buttons to insert specific text somewhere else when any button is selected.... Can anybody help me?  Youtube is only getting me so far, and my kids are driving me nuts while I'm trying to figure this monster out...  I've gotten several slides created and some screens have several buttons, I just need to see what I need to put in the code to get it to do this type of function 

    Also where can I read up on setting my .Xdefaults and xmonad.hs file? I ripped someones from this forum, and it works nice, but I want to make my onw, but cant find any decent documentation. Thanks.
    At the moment, the best source for configs are those posted in the screenshots thread (for both Xdefaults and xmonad.hs), the xmonad config archive (and the available docs from the root page on that site), and our own thread.  Unfortunately you'll have to sort of scrounge for good docs on the xmonad.hs at the moment, since most of the information was written for the 0.4 version of xmonad.  The configuration has since been made MUCH simpler.
    Hope that helps some.

  • Help with a program book ad page

    Hello,
    I have finished creating an ad for a program book and I cannot get it to either print right or when I did get it to do right I now have a right margin going into the crease and I have my ad going over the 1/4 margins on the bottom.
    First I set up a 8.5 in by 5.5 in page size (size of program book) because I am only going to be using 1/2 of that page for my ad. I finished my design, then printed it out. My design came out landscape on the page, rather than upright portrait on the page. Obviously I think Im getting its because of the way it wants to print it.  There are not many choices given in the print options for telling it to print a certain way (at least I cant find it).
    Now, after messing with that a few times, I somehow finally got it to print at the top left of my paper (it actually doesnt matter if its at the top or bottom).  When I fold it to 8.5 in x 5.5 in and fold the book in half I can see its not set up correct.  I am not sure if its on my end or if its the printer again.  The right margin runs into the spine of my paper (or crease) and the bottom of my ad has run over the middle crease. My left margin is at least 1/2" away from the left edge of my paper. I need my ad to be 1/2 the page of a 8.5in x 5.5 in page. The ad's are sold as a full page or 1/2 page.
    My page set up is as a document.  Its set as Page Size: Letter - 1/2 (I did not set this?), width 5.5 in and height 8.5 in, orientation is Portrait. I do have a bleed, but I dont need it and ignore it.  Ive started my ad at the top Margin lines, but I made ad short of the right margin, so as to leave room near the inside crease where it would be stapled. I did not set up these margin lines and not sure how to change it. When I added my background artwork, I pulled it down till it turned PINK so that I would know where the middle of the page is. But my ad prints over this.
    I am needing this ad to be at least 1/2" away from the top, left and right margin of the page and pretty close to the 1/2 page mark, but not over.  Do i make sense?
    Now, just a little back ground. Ive designed program books in the past using Publisher.  I designed a whole program book, cover to cover and I had very little issues doing it.  Now I am using InDesign for the first time to do this and struggling a bit here.  The printing of stuff from ID is also driving me nuts. Im not liking the way ID prints and if I tell my Epson printer how to print, it doesnt work and continues to give me crappy outputs.
    Any help would be appreciated.  I need to turn this in tonight, but i cant turn in a camera ready printout if its not printing out correctly.
    Thank you,
    Tina

    NeverWasBefore wrote:
    So, whatever is the easiest way for her to get this ad, so that she doesnt somehow mess it up.
    You really can't control for that. If she doesn't know what she's doing, you could send her a technician with a brand new printer, and she could do it wrong. The best you can do is to communicate to her what you intend, and hope she can pull it off. I'd send a PDF set to the final size with the margins, and one without the margins. When she opens them, she will see something like this:
    This is a screenshot from Acrobat showing the white document size against the black background that represents what is outside of the document. You can see the amount of white space that surrounds the image area (the placeholder type), so you know how much border you intended.
    Now, your InDesign document is half-letter size (5.5x8.5). If you subtract the amount of margin you used (in my example, I used .5" on all sides), you have the size of the image area (my example has a 4.5x7.5 image area). You can make a new InDesign document the size of your image area (4.5x7.5) and place the PDF that has the margins (like in the screenshot above) onto the page and position it so that the image area lines up with the document page borders, as you can see in this screenshot:
    You can see the blue InDesign image frame with the handles, which is the size of the half-letter PDF, and the image area contained within the document border, which is the black stroke that you normally see in InDesign. Don't worry about the magenta inner margin—that could be set to anything, and isn't in play here. In order to position the placed PDF into the new 4.5x7.5 InDesign document, when you place the PDF, check the Show Import Options box in the Place window. that will bring up a new screen after you select which image you are placing and you hit the OK button. The screen looks like this:
    In the Options section, change the Crop to from Bounding Box (Visible Layers only) (which should be the default choice) to Art, and you will see the dotted line that represents the size of the image change to include the margins.
    Now, when you place the image, just set the position proxy (which looks like this: ) to the top left corner and in the X and Y fields, enter the negative of the amount of margin you have. Since I used .5" margins, I set X and Y to -.5" each, and that aligned the image area of the larger PDF to the document borders of the smaller InDesign document. You could just eyeball it in if you want, but this way you can be a little more sure you aren't cutting off a hair of some of your image area.
    If you export that document to PDF, it will look like this:
    …which the person who will be putting this together will probably use, since it will be easier to place into something like Publisher or Word because it is smaller than a half page (an image that is larger than the document will probably be reduced in size to fit automatically—something that Word does, and maybe Publisher does that too, but I don't use Publisher so I don't know). How She positions it within the page is up to her, and not something you can control unless you are in the room with her, so it's a crapshoot. She could also use the PDF with the margins if it works better for her, but all you can do is explain to her what you are sending and what you would like.

  • Help with a Program I am writing!  Please!

    Hello All,
    This is my first post...I hope to find some answers to my program I am writing! A couple things first - I am 17, and have designed a comp. science class for myself to take while a senior in high school, since there was not one offered. My end of the 2nd term project is to write a program that encompasses the information I have learned about for the past two terms. I know the very basics, if that. Please help!
    My program involves the simple dice throwing program, 'Dice Thrower' by Kevin Boone. The full text/program write out can be found at:
    http://www.kevinboone.com/PF_DiceThrower-java.html
    I am hoping to add a part to this program that basically tells the program if the dice show doubles, pop up a little GUI window that says "You are a Winner! You Got Doubles!"
    I was thinking as I finished chapter 7 in my text book, that either an 'if/else' or 'switch' statement might be the right place to start.
    Could someone please write me a start to the program text that I need to add to 'Dice Thrower', or explain what I need to do to get started! Thank you so much, I really appreciate it.
    Erick DeVore - Eroved Kcire

    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JLabel;
    import javax.swing.JFrame;
    import java.awt.FlowLayout;
    import java.awt.Color;
    public class DiceThrower extends Applet
    Die die1;
    Die die2;
    public void paint (Graphics g)
         die1.draw(g);
         die2.draw(g);
         g.drawString ("Click mouse anywhere", 55, 140);
         g.drawString ("to throw dice again", 65, 160);
    public void init()
         die1 = new Die();
         die2 = new Die();
         die1.setTopLeftPosition(20, 20);
         die2.setTopLeftPosition(150, 20);
         throwBothDice();
         // Erick's Program Insert below
         public class WinnerGui extends JFrame;
      public WinnerGui();
        super ("You Are The Winner with GUI");
        Container c = getContentPane();
        c.setBackground(Color.lightGray);
        c.setLayout(new FlowLayout());
        c.add(new JLabel("You're a Winner! You Got Doubles!"));
            //End Erick's Program insert
         DiceThrowerMouseListener diceThrowerMouseListener =
              new DiceThrowerMouseListener();
         diceThrowerMouseListener.setDiceThrower(this);
         addMouseListener(diceThrowerMouseListener);
    public void throwBothDice();
         die1.throwDie();
         die2.throwDie();
         repaint();
    class Die
    int topLeftX;
    int topLeftY;
    int numberShowing = 6;
    final int spotPositionsX[] = {0, 60,  0, 30, 60,  0,  60};
    final int spotPositionsY[] = {0,  0, 30, 30, 30,  60, 60};
    public void setTopLeftPosition(final int _topLeftX, final int _topLeftY)
         topLeftX = _topLeftX;
         topLeftY = _topLeftY;
    public void throwDie()
         numberShowing = (int)(Math.random() * 6 + 1);
    public void draw(Graphics g)
         switch(numberShowing)
              case 1:
                   drawSpot(g, 3);
                   break;
              case 2:
                   drawSpot(g, 0);
                   drawSpot(g, 6);
                   break;
              case 3:
                   drawSpot(g, 0);
                   drawSpot(g, 3);
                   drawSpot(g, 6);
                   break;
              case 4:
                   drawSpot(g, 0);
                   drawSpot(g, 1);
                   drawSpot(g, 5);
                   drawSpot(g, 6);
                   break;
              case 5:
                   drawSpot(g, 0);
                   drawSpot(g, 1);
                   drawSpot(g, 3);
                   drawSpot(g, 5);
                   drawSpot(g, 6);
                   break;
              case 6:
                   drawSpot(g, 0);
                   drawSpot(g, 1);
                   drawSpot(g, 2);
                   drawSpot(g, 4);
                   drawSpot(g, 5);
                   drawSpot(g, 6);
                   break;
    void drawSpot(Graphics g, final int spotNumber)
         g.fillOval(topLeftX + spotPositionsX[spotNumber],
              topLeftY + spotPositionsY[spotNumber], 20, 20);
    class DiceThrowerMouseListener extends MouseAdapter
    DiceThrower diceThrower;
    public void mouseClicked (MouseEvent e)
         diceThrower.throwBothDice();
    public void setDiceThrower(DiceThrower _diceThrower)
         diceThrower = _diceThrower;
    }That was what I have dwindled it down to, using my knowledge, as well as others' expertise...however I am listening to what you say, and get these messages when I try to compile in the CMD:
    line 63 - illegal start of expression (carrot at p in public)
    line 63 - ; expected (carrot at c in class)
    line 63 - { expected (carrot at ; at end of line)
    line 65 - illegal start of expression (carrot at p in public)
    line 83 - <identifier> expected (carrot as: (this) ) -- I don't even know what that means ^
    line 84 - invalid method declaration; return type required (carrot at a in add)
    line 84 - <identifier> expected (carrot like this: [see below])
    addMouseListener(diceThrowerMouseListener);
    ^
    line 84 - ) expected (carrot is one place over from previous spot [see above]
    line 93 - illegal start of expression (carrot at p in public)
    I know this seems like a lot of errors, but believe it or not, I actually had it up in the high teens and was able to fix some of them myself from going by previous examples, as well as looking things up in my text book. If anyone has any suggestions concerning the syntax errors of the code, please please let me know and I will work my hardest to fix them...thank you all so much for helping.
    Erick

  • Need a little help with RAF logic

    So Im making a program to give different users, different rights. This is the method that appends them to file and Map
         * Writes the players rights to the appendages
         * @param playerName Player to update
         * @param playerRights Rights to give the player
         * @param pointer The lines index in the files
         * @throws IOException If a read/write error occours
        public void writeRights(String playerName, Rights playerRights, long pointer) throws IOException {
            rightsRAF.seek(pointer);
            rightsRAF.write(("\n" + playerName + "::" + playerRights).getBytes());
            if(rightsRAF.read() != '\n') {
                rightsRAF.seek(rightsRAF.getFilePointer()-1);
                rightsRAF.write("\n".getBytes());
            rightsMap.put(playerName, playerRights);
        }1. The RAF goes to the predetermined index in the file, pointer, which is the line the users name starts on. Entries are stored in the file as "name::RIGHTS"
    2.It writes out the players name, and rights
    3. It checks to see if it accidentally wrote over the \n
    My problem now, is that some rights are longer than others. For example, if there was already an entry, "name::MODERATOR" and you overwrite it, with "name::OWNER" then it would turn into "name::OWNERATOR" because the rest of the line wasn't overwritten.
    I need some help with logic to determine how to overwrote the entire line, because sometimes you could go from a short one, to a long one, and need to append a new \n character, and sometimes you could go the other way around from long to short and end up with two words fused, I cant figure out how to determine whats a word that got partially overwritten and whats a new line totally.
    Thanks

    As pointed out you need to have fixed size records, or at least a maximum size.
    You also have another problem nobody commented on yet (I don't think) with the getBytes() calls. At that point in your code you will mangle most unicode Strings.
    All things being equal here I think your best solution is to use an embedded database like JavaDB with JDBC. I think you will find an XML solution to slow for your purposes.
    If you decide to continue the RAF route though here is an example. I know this is not exactly what you are doing but you can extrapolate from this...
    public void updatePlayerName(String playerName, int playerIndex){
       int recordlength = 200;  
       byte[] buff = playerName.getBytes("UTF-8");
       if(buff.length>recordlength){
          //truncate bytes. this is also not great because a character at the end could be mangled
          byte[] temp = new byte[recordlength];
          System.arraycopy(buff,0,temp,0,temp.length);
          buff = temp;
       long pointer = playerIndex * (recordlength+4);// plus 4 bytes per record for actual length
       raf.seek(pointer);
       raf.writeInt(buff.length);
       raf.write(buff);
    public String getPlayerName(int playerindex){
        int recordlength = 200;  
        long pointer = playerIndex * (recordlength+4);
        raf.seek(pointer);
        int lengthToRead = raf.readInt();
        //length to read should be checked for sanity or bad things will happen next
        byte[] buff = new byte[lengthToRead];
        raf. readFully(buff);
        return new String(buff,"UTF-8");
    }And then of course you'd have to add storing the "rights". It gets complicated in a hurry. I do really recommend the JDBC route.

  • Need Help With Shell Programming

    Hi, I need some guidance as to how to approach my project.
    I need to develop a shell to host an e-learning environment that can be accessed through the internet. The user, preferably, needs not to download anything to run/start the e-learning environment. This e-learning environment allows users/students to create a forum, create a chatroom, hand up projects, send mail, do surveys and tutorials online and these can be submitted to the teacher/marker and receive feedback and also view their grades and schedule. Eg, Blackboard http://www.blackboard.com/
    The problem is is that there seems to be no shell programming by using java. I have found only shell programming using UNIX, korn and C. I read other posts in the forums here concerning shell programming and alot of the codes include the first 2 lines :
    Runtime rt = Runtime.getRuntime();      
    String command = "your_shell_script_command";      
    try {           
          Process process = rt.exec(command);           
         from = new BufferedReader(new InputStreamReader(process.getInputStream()));           
         to = new PrintWriter(process.getOutputStream(), true);      
    catch (IOException e) {         ...       }the above codes were taken from this post: http://forum.java.sun.com/thread.jsp?forum=57&thread=352231
    Does it means that I need to use another language besides Java to program a shell and then run it together with my java program? If so, what language do I need to learn and what Java "component" do I need to use? and is it possible to run a shell in an applet, since the applet is viewable through a browser?
    I really need some help on this problem as I don't have a clue to go about it at all. Thanks in advance.

    er, actually the applet does not seem to load at all.
    But from what you have written, yeah, I need to
    process the user's input and in my case, his
    selected/choosen options in a menu.
    E.g, the user wants to create a forum, he/she chooses
    the create forum option from the menu which is part of
    the shell and something happens which allows the user
    to customise the forum.
    So, let me get this straight, I can create an applet
    and run the shell on the applet and the user can view
    this application without downloading anything? As YAT said...providing they have the java plugin...yes... if you keep it to java.applet.Applet (AWT) and not JApplet, you should even have more users able to run it without 'downloading' anything..
    Now..to be clear... they ARE downloading your .class files, and running them within a JVM on their own local machine... But they will not need anything (assuming their browser supports the Java version you write in) else...

  • Need some help with a program Please.

    Well, im new here, im new to java, so i need your help, i have to make a connect four program, my brother "Kind of" helped me and did a program for me, but the problem is i cant use some of those commands in the program and i have to replace them with what ive learned, so i will post the program and i will need your help to modify it for me.
    and for these programs, also i want help for:
    They have errors and i cant fix'em
    the commands that i've leaned:
    If statements, for loops, while loops,do while, strings, math classes, swithc statement, else if,logical operators,methods, one and two dimensional arrays.
    Thanx in advance,
    truegunner
    // Fhourstones 3.0 Board Logic
    // Copyright 2000-2004 John Tromp
    import java.io.*;
    class Connect4 {
    static long color[]; // black and white bitboard
    static final int WIDTH = 7;
    static final int HEIGHT = 6;
    // bitmask corresponds to board as follows in 7x6 case:
    // . . . . . . . TOP
    // 5 12 19 26 33 40 47
    // 4 11 18 25 32 39 46
    // 3 10 17 24 31 38 45
    // 2 9 16 23 30 37 44
    // 1 8 15 22 29 36 43
    // 0 7 14 21 28 35 42 BOTTOM
    static final int H1 = HEIGHT+1;
    static final int H2 = HEIGHT+2;
    static final int SIZE = HEIGHT*WIDTH;
    static final int SIZE1 = H1*WIDTH;
    static final long ALL1 = (1L<<SIZE1)-1L; // assumes SIZE1 < 63
    static final int COL1 = (1<<H1)-1;
    static final long BOTTOM = ALL1 / COL1; // has bits i*H1 set
    static final long TOP = BOTTOM << HEIGHT;
    int moves[],nplies;
    byte height[]; // holds bit index of lowest free square
    public Connect4()
    color = new long[2];
    height = new byte[WIDTH];
    moves = new int[SIZE];
    reset();
    void reset()
    nplies = 0;
    color[0] = color[1] = 0L;
    for (int i=0; i<WIDTH; i++)
    height[i] = (byte)(H1*i);
    public long positioncode()
    return 2*color[0] + color[1] + BOTTOM;
    // color[0] + color[1] + BOTTOM forms bitmap of heights
    // so that positioncode() is a complete board encoding
    public String toString()
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<nplies; i++)
    buf.append(1+moves);
    buf.append("\n");
    for (int w=0; w<WIDTH; w++)
    buf.append(" "+(w+1));
    buf.append("\n");
    for (int h=HEIGHT-1; h>=0; h--) {
    for (int w=h; w<SIZE1; w+=H1) {
    long mask = 1L<<w;
    buf.append((color[0]&mask)!= 0 ? " @" :
    (color[1]&mask)!= 0 ? " 0" : " .");
    buf.append("\n");
    if (haswon(color[0]))
    buf.append("@ won\n");
    if (haswon(color[1]))
    buf.append("O won\n");
    return buf.toString();
    // return whether columns col has room
    final boolean isplayable(int col)
    return islegal(color[nplies&1] | (1L << height[col]));
    // return whether newboard lacks overflowing column
    final boolean islegal(long newboard)
    return (newboard & TOP) == 0;
    // return whether newboard is legal and includes a win
    final boolean islegalhaswon(long newboard)
    return islegal(newboard) && haswon(newboard);
    // return whether newboard includes a win
    final boolean haswon(long newboard)
    long y = newboard & (newboard>>HEIGHT);
    if ((y & (y >> 2*HEIGHT)) != 0) // check diagonal \
    return true;
    y = newboard & (newboard>>H1);
    if ((y & (y >> 2*H1)) != 0) // check horizontal -
    return true;
    y = newboard & (newboard>>H2); // check diagonal /
    if ((y & (y >> 2*H2)) != 0)
    return true;
    y = newboard & (newboard>>1); // check vertical |
    return (y & (y >> 2)) != 0;
    void backmove()
    int n;
    n = moves[--nplies];
    color[nplies&1] ^= 1L<<--height[n];
    void makemove(int n)
    color[nplies&1] ^= 1L<<height[n]++;
    moves[nplies++] = n;
    public static void main(String argv[])
    Connect4 c4;
    String line;
    int col=0, i, result;
    long nodes, msecs;
    c4 = new Connect4();
    c4.reset();
    BufferedReader dis = new BufferedReader(new InputStreamReader(System.in));
    for (;;) {
    System.out.println("position " + c4.positioncode() + " after moves " + c4 + "enter move(s):");
    try {
    line = dis.readLine();
    } catch (IOException e) {
    System.out.println(e);
    System.exit(0);
    return;
    if (line == null)
    break;
    for (i=0; i < line.length(); i++) {
    col = line.charAt(i) - '1';
    if (col >= 0 && col < WIDTH && c4.isplayable(col))
    c4.makemove(col);
    By the way im using Ready to program for the programming.

    You can't really believe that his brother did this
    for him...I did miss that copyright line at the beginning when
    I first looked it over, but you know, if it had been
    his brother, I'd be kinda impressed. This wasn't a
    25 line program. It actually would have required
    SOME thought. I doubt my brother woulda done that
    for me (notwithstanding the fact that I wouldn't need
    help for that program, and my brother isn't a
    programmer).I originally missed the comments at the top but when I saw the complexity of what was written then I knew that it was too advanced for a beginner and I relooked through the code and saw the comments.

Maybe you are looking for

  • How to create a selection or mask from a Selective Color layer

    Hi. I was wondering if it is possible to get a selection/mask out of a Selective Color Layer. For instance lets say I have a complicated photo and I put a Selective Color layer on.  I then pick Red and start adjusting. I can see the effect and how it

  • Struts-Portlet

    Hello, I have created a very simple login form that uses the struts framework. It validates that there is a userid and password in the textfields before it submits through the action. The problem is, the only way I can get the portlet to recognize th

  • Problem while installing Dektop Manager 6.0

    Hi, I am trying to install BB Desktop manager 6 on my PC. However, I am constantly getting the following windows installer message window and the setup is not continuing beyond this. My OS is Win XP with SP 3. Let me know if anyone has a solution to

  • Username - case sensitivity and embeded period

    I have been asked to investigate the impact of syncing our oracle user names with our AD names .. which would mean putting a period (dot) in the username. (example - john.doe). First attempt to create one returned an error which lead to the following

  • Discoverer Preferred Preferences

    Our environment: OracleBI Discoverer 10g (10.1.2.2) Oracle Business Intelligence Discoverer Plus 10g (10.1.2.54.25) Discoverer Model - 10.1.2.54.25 Discoverer Server - 10.1.2.54.25 End User Layer - 5.1.1.0.0.0 End User Layer Library - 10.1.2.54.25 Or