im using the book java in 24 hours.
i still need to learn about input but disregard that
i only wanna know you opinians about my code
thanks for your support

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;

/**
 *
 * @author Jan
 */
public class Students {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        //input system!!
        String[][] namesAv = new String[50][3];
        boolean input = false;//THIS BOOLEAN IS FALSE BECAUSE DE INPUT SYSTEM ISNT READY!!!!!!!!!!!!!!!!
        char chInput = '0';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        int i = 0, si = 0;
        while(input){
            System.out.println("Geef de naam van de student?");
            ////System.in.blabla(namesAv[i][si];
            i++;
            System.out.println("Geef de punten van de eerste helft?");
            i++;
            si++;
            ////System.in.blabla(namesAv[i][si];
            System.out.println("Geef de punten van de tweede helft?");
            ////System.in.blabla(namesAv[i][si];
            i++;
            si++;
            System.out.println("Druk c om meer inputs te doen!");
            
            
            System.out.println("Druk q om te stoppen met de input!");
            //note ik ken het input systeem van java niet!!!!!!!!!!!!!!!!!!!!
            //NOTE I DONT KNOW THE INPUT CLASSES OF JAVA SO NEED TO LEARN THAT FIRST!!!!!!!!!!!!!!!!!!!!
            if(chInput == 'c'|| chInput == 'C')
                input = true;
            if(chInput == 'q'|| chInput == 'Q')
                input = false;
        }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////        
        //THIS HARD CODED ARRAY IS BECAUSE I NEED TO LEARN ABOUT INPUT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        namesAv[0][0] = "jan";  namesAv[0][1] = "50";
        namesAv[1][0] = "eefje"; namesAv[1][1]= "100";
        namesAv[2][0] = "baltazar";
        namesAv[3][0] = "xavier";
        namesAv[4][0] = "carmen";
        namesAv[5][0] = "bieke";
        namesAv[6][0] = "teefje";
        int length = 0;
        while(namesAv[length][0] != null){length++;}
        i = 0;
        while(i < length){
            System.out.print(namesAv[i][0]+" ");
            if(namesAv[i][1] != null)
                System.out.print(namesAv[i][1]+" ");
            if(namesAv[i][2] != null)
                System.out.println(namesAv[i][2]);
            else {System.out.println();}


            i++;
        }
    }

}
VernonDozier commented: Used code tags on first post. +15

Recommended Answers

All 5 Replies

coding standards are a good practice to follow, and I guess it is a good thing you are trying to achieve a good standard. I believe there are some published guidelines available, which will give you a good base.

Based on my opinion (this is a very subjective topic), I'd say you want to make use of some more whitespace, and you need to do something about your ugly commenting. Remember... my opinion

Thanks for the respons :)
il keep that in mind

hi this is a second aproach that i tryed

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
/**
 *
 * @author Maria
 */
public class Students {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Random rNum = new Random();
        int SECOND_INDEX = 3;
        String[][] studenten = new String[50][SECOND_INDEX];
        int buffer;
        studenten[0][0] = "Jan";
        studenten[1][0] = "Eefje";
        studenten[2][0] = "Diana";
        studenten[3][0] = "Foefke";
        studenten[4][0] = "Sloefke";
        studenten[5][0] = "Onbeleeftje";
        
        int si = 1;
        while( si < SECOND_INDEX){
            for(int i = 0;i < studenten.length; i++){
                buffer = rNum.nextInt(21)+10;
                studenten[i][si] = Integer.toString(buffer);
            }
            si++;
        }
        int i = 0;
        int fi = 1;
        for(int ti = 0;ti < 6;ti++){
            System.out.println(studenten[ti][0]+"");
            System.out.println("   "+studenten[i][fi]);
            i++;
        }
    }
}

looks a lot better, my code would probably look very similar to that.

how far are u in de java knowledge ?
ive programd before but now im learning much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.