hello.i have a homework in java wich asks to create this program:
there would be n persons who are going to rate songs.
for n persons we will ask their name,surname,sex and age.after this each person will rate(vote) with points the song we have given to them.there are 15 songs and they are constant.at the end pint the most 10 rated song...
thnx :)

hello.i have a homework in java wich asks to create this program:
there would be n persons who are going to rate songs.
for n persons we will ask their name,surname,sex and age.after this each person will rate(vote) with points the song we have given to them.there are 15 songs and they are constant.at the end pint the most 10 rated song...
thnx :)

Great... but what are the problems that you are having? have you any code to show where the problem is occurring or any specific questions on the app? because you asked nothing you just told us about your assignment...

i would like you to help me build it.if you can :)

This is and never has been a homework service center. It works on the basis you show us code or asks questions and we either show or help you to gain the knowledge in getting around/solving your problem.

and to be a bit more specific: the amount of help you will receive also depends on how you define "help me build it".
btw, yes, yes we can, but we are not going to spend our time making your teacher believe you know what you are doing without seeing a bit of effort from your part.

ok then.how can we use the constructer examle(String name[],String surname[], int age[]){
....}
in void main ???

ok then.how can we use the constructer examle(String name[],String surname[], int age[]){
....}
in void main ???

a constructor belongs in the class who's name it posses and not in any method...

public class X {
public X(String name[],String surname[], int age[]) {
}
   public static void main(String[] args) {
    }
}

Edited 4 Years Ago by DavidKroukamp: n/a

ok until here we are ok.
but i have to build a void where i can get info from the user.
and after i finish this, i have to make void main to make this void work

big no.
you can't get info from 'a void'. a method that has void as return type, returns nothing.

you'll need to use get- and set-methods, and I assume the names by themselves are quite self-explaining

ok lets do like this.i have solved this example all in the void main.but they ask to use contructor or classes.
this is what i've done, can you help me convert it in voids and constructors.
comments are non in englisht.no time to translate them.sorry.
have a look in my progam:

package prova;
import java.util.Scanner;//meqe kemi perdorur scanner duhet ta bejme import
public class Anketimi {
    public static void main(String[] args) {
        String songet[]=new String[21];//vektori qe do te mbaje songet
        songet[1]="1.Adele-Someone like you                         ";//songet e secilit indeks
        songet[2]="2.Elton John-Sorry seems to be the hardest word  ";//...
        songet[3]="3.Beyonce-Halo                                   ";//kemi lene hapsira pas cdo string songe
        songet[4]="4.Rihanna-Cheers                                 ";//..qe teafishohen ne vije te drejte ne fund
        songet[5]="5.Metallica-Unforgiven                           ";
        songet[6]="6.Bon Jovi-Runaway                               ";
        songet[7]="7.Linkin Park-Iridescent                         ";
        songet[8]="8.Michael Jackson-They really don't care about us";
        songet[9]="9.Michael Buble-Home                             ";
        songet[10]="10.Enrique Iglesias-Tonight                      ";
        songet[11]="11.Mariah Carey-Hero                             ";
        songet[12]="12.Avril Lavigne-Girlfriend                      ";
        songet[13]="13.Nickelback-Rockstar                           ";
        songet[14]="14.Taylor Swift-Love Story                       ";
        songet[15]="15.Shakira-Waka Waka                             ";
        songet[16]="16.Jenifer Lopez-I'm into you                    ";
        songet[17]="17.Michel Telo-Ai se tu pego                     ";
        songet[18]="18.Fly Project-Goodbye                           ";
        songet[19]="19.Alexandra Stan-Get back                       ";
        songet[20]="20.Mango-La rondina                              ";
        int points[]=new int[21];//vektori qe do te mbaje pointe e cdo songe.
        //vlerat fillestare jane 0 te cdo songe.
        for(int i=1;i<points.length;i++){//mbushja e pointeve te çdo indeksi me 0
            points[i]=0;
        }//end for
       
         Scanner s=new Scanner(System.in);//inicialiimi i scanerit
        System.out.println("Sa persona do te anketoheni:");
      int persona=s.nextInt();//do te ruaje se sa here do te ekzekutohet cikli i anketuesit
      String name[]=new String[persona];//stringjet qe do mbajne te dhena per cdo te anketuar
      String surname[]=new String[persona];
      String sex[]=new String[persona];
      int age[]=new int[persona];
   for(int i=0;i<name.length;i++){//marrja e te dhenave per cdo anketues
       System.out.println("your name :");
      name[i]=s.next();//ruajta ne memorie e namet te anketuesi
      System.out.println("your surname: ");
      surname[i]=s.next();
      System.out.println("ur sex :(m/f) ");
      sex[i]=s.next();
      System.out.println("ur age juaj: ");
      age[i]=s.nextInt();
       }//morem info rreth anketuesit
   System.out.println("Te dhenat e anketuesve");//afishimi i infove te anketuesve
   System.out.println("name\t\tsurname\t\tsex\tage");
   for(int i=0;i<persona;i++){//perseritje e ciklit per aq persona sa kemit
       System.out.println(name[i]+"\t\t"+surname[i]+"\t\t"+sex[i]+"\t"+age[i]);
   }
   for(int i=0;i<persona;i++){//votimi i cdo te anketuari 
       System.out.print(name[i]+" te votoje 5 songe.\nKeta jane songet qe mund te votosh:\n");
       System.out.println("songet\t\t\t\t\t\t\tpoints");
       for(int j=1;j<songet.length;j++){
           System.out.println(songet[j]+"\t"+points[j]);//afishimi songeve dhe pointeve perkatese
       }
    for(int k=1;k<=5;k++){//secili person do te votoje 5 songe
        System.out.println("Jepni numrin e songes qe doni te votoni:");
        int song=s.nextInt();//indeksi i songes qe do te votoje
        if(song<0||song>20){//kontrollojme qe nr te songes te jete brenda vektorit tone.
            System.out.println("Nuk ka aq songe!");
            break;}//mbyllet kushti if
        System.out.println("Ju zgjodhet songen:"+songet[song]+".\nJepni points qe i jepni kesaj songe:");
        int point=s.nextInt();
        points[song]=points[song]+point;
    }//for i 5 songeve
       }//for i nr te personave qe votojne
   for(int i=1;i<songet.length;i++){//cikli qe do te rendis sipas pointeve
       for(int j=i+1;j<songet.length;j++){
           if(points[i]>points[j]){
               int temp=points[i];
               points[i]=points[j];
               points[j]=temp;
               String tempi=songet[i];
               songet[i]=songet[j];
               songet[j]=tempi;
           }//end if
       }//end for i j-se
   }//end for i i-se
   System.out.println("\n");
   System.out.println("songet sipas renditjes qe kane me shume se 0 pointë");
   System.out.println("songet\t\t\t\t\t\tpoints");
   for(int i=20;i>1;i--){
   if(points[i]==0){     continue;    }   //te mos afishoje songet me 0 pointe
   System.out.println(songet[i]+" "+points[i]);
   }//cikli for per songet me pointe > 0
   System.out.println("\n");
    System.out.println("10 songet me te votuara:");
    System.out.println("songet\t\t\t\t\t\tpoints");
   for(int i=20;i>10;i--){//afishimi i 10 songeve me te votuara
   if(points[i]==0){     continue;    }   //te mos afishoje songet me 0 pointe
   System.out.println(songet[i]+" "+points[i]);
   }//mbarim i ciklit per 10 songet me te votuara
    for(int i=0;i<persona;i++){//cikli qe kontrollon personat me emer te njejte
        for(int j=i+1;j<persona;j++){
            if( name[i].equals(name[j])){
               System.out.println("Personat qe kane te njejtin emer jane:"+name[i]); //afishon emerin e  personave me emer te njejte
            }//enf if
        }//end for i j-se
            }//end for i i-se
    for(int i=0;i<persona;i++){//cikli qe kontrollon personat me mbiemer te njejte
        for(int j=i+1;j<persona;j++){
            if( surname[i].equals(surname[j])){
               System.out.println("Personat qe kane te njejtin mbiemer jane:"+surname[i]); //afishon surnamen e personave me mbiemer te njejte
            }//end if
        }//end for i j-se
            }//end for i i-se
    
    }    //mbaron metoda main
}//mbaron klasa

Edited 4 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

do you have any experience with creating objects?
step 1: create an analysis (just write down what your app has to do)
step 2: underline all the nouns with red
step 3: underline all the verbs with blue

the red underlined words are the objects you'll have to create
the blue underlined words are functionalities (methods)

this is my finished example.all i have to do is to use contructor, objetct, or classes inside main class.can you convert ?

package prova;
import java.util.Scanner;//meqe kemi perdorur scanner duhet ta bejme import
public class Anketimi {
    public static void main(String[] args) {
        String songet[]=new String[21];//vektori qe do te mbaje songet
        songet[1]="1.Adele-Someone like you                         ";//songet e secilit indeks
        songet[2]="2.Elton John-Sorry seems to be the hardest word  ";//...
        songet[3]="3.Beyonce-Halo                                   ";//kemi lene hapsira pas cdo string songe
        songet[4]="4.Rihanna-Cheers                                 ";//..qe teafishohen ne vije te drejte ne fund
        songet[5]="5.Metallica-Unforgiven                           ";
        songet[6]="6.Bon Jovi-Runaway                               ";
        songet[7]="7.Linkin Park-Iridescent                         ";
        songet[8]="8.Michael Jackson-They really don't care about us";
        songet[9]="9.Michael Buble-Home                             ";
        songet[10]="10.Enrique Iglesias-Tonight                      ";
        songet[11]="11.Mariah Carey-Hero                             ";
        songet[12]="12.Avril Lavigne-Girlfriend                      ";
        songet[13]="13.Nickelback-Rockstar                           ";
        songet[14]="14.Taylor Swift-Love Story                       ";
        songet[15]="15.Shakira-Waka Waka                             ";
        songet[16]="16.Jenifer Lopez-I'm into you                    ";
        songet[17]="17.Michel Telo-Ai se tu pego                     ";
        songet[18]="18.Fly Project-Goodbye                           ";
        songet[19]="19.Alexandra Stan-Get back                       ";
        songet[20]="20.Mango-La rondina                              ";
        int points[]=new int[21];//vektori qe do te mbaje pointe e cdo songe.
        //vlerat fillestare jane 0 te cdo songe.
        for(int i=1;i<points.length;i++){//mbushja e pointeve te çdo indeksi me 0
            points[i]=0;
        }//end for
       
         Scanner s=new Scanner(System.in);//inicialiimi i scanerit
        System.out.println("Sa persona do te anketoheni:");
      int persona=s.nextInt();//do te ruaje se sa here do te ekzekutohet cikli i anketuesit
      String name[]=new String[persona];//stringjet qe do mbajne te dhena per cdo te anketuar
      String surname[]=new String[persona];
      String sex[]=new String[persona];
      int age[]=new int[persona];
   for(int i=0;i<name.length;i++){//marrja e te dhenave per cdo anketues
       System.out.println("your name :");
      name[i]=s.next();//ruajta ne memorie e namet te anketuesi
      System.out.println("your surname: ");
      surname[i]=s.next();
      System.out.println("ur sex :(m/f) ");
      sex[i]=s.next();
      System.out.println("ur age juaj: ");
      age[i]=s.nextInt();
       }//morem info rreth anketuesit
   System.out.println("Te dhenat e anketuesve");//afishimi i infove te anketuesve
   System.out.println("name\t\tsurname\t\tsex\tage");
   for(int i=0;i<persona;i++){//perseritje e ciklit per aq persona sa kemit
       System.out.println(name[i]+"\t\t"+surname[i]+"\t\t"+sex[i]+"\t"+age[i]);
   }
   for(int i=0;i<persona;i++){//votimi i cdo te anketuari 
       System.out.print(name[i]+" te votoje 5 songe.\nKeta jane songet qe mund te votosh:\n");
       System.out.println("songet\t\t\t\t\t\t\tpoints");
       for(int j=1;j<songet.length;j++){
           System.out.println(songet[j]+"\t"+points[j]);//afishimi songeve dhe pointeve perkatese
       }
    for(int k=1;k<=5;k++){//secili person do te votoje 5 songe
        System.out.println("Jepni numrin e songes qe doni te votoni:");
        int song=s.nextInt();//indeksi i songes qe do te votoje
        if(song<0||song>20){//kontrollojme qe nr te songes te jete brenda vektorit tone.
            System.out.println("Nuk ka aq songe!");
            break;}//mbyllet kushti if
        System.out.println("Ju zgjodhet songen:"+songet[song]+".\nJepni points qe i jepni kesaj songe:");
        int point=s.nextInt();
        points[song]=points[song]+point;
    }//for i 5 songeve
       }//for i nr te personave qe votojne
   for(int i=1;i<songet.length;i++){//cikli qe do te rendis sipas pointeve
       for(int j=i+1;j<songet.length;j++){
           if(points[i]>points[j]){
               int temp=points[i];
               points[i]=points[j];
               points[j]=temp;
               String tempi=songet[i];
               songet[i]=songet[j];
               songet[j]=tempi;
           }//end if
       }//end for i j-se
   }//end for i i-se
   System.out.println("\n");
   System.out.println("songet sipas renditjes qe kane me shume se 0 pointë");
   System.out.println("songet\t\t\t\t\t\tpoints");
   for(int i=20;i>1;i--){
   if(points[i]==0){     continue;    }   //te mos afishoje songet me 0 pointe
   System.out.println(songet[i]+" "+points[i]);
   }//cikli for per songet me pointe > 0
   System.out.println("\n");
    System.out.println("10 songet me te votuara:");
    System.out.println("songet\t\t\t\t\t\tpoints");
   for(int i=20;i>10;i--){//afishimi i 10 songeve me te votuara
   if(points[i]==0){     continue;    }   //te mos afishoje songet me 0 pointe
   System.out.println(songet[i]+" "+points[i]);
   }//mbarim i ciklit per 10 songet me te votuara
    for(int i=0;i<persona;i++){//cikli qe kontrollon personat me emer te njejte
        for(int j=i+1;j<persona;j++){
            if( name[i].equals(name[j])){
               System.out.println("Personat qe kane te njejtin emer jane:"+name[i]); //afishon emerin e  personave me emer te njejte
            }//enf if
        }//end for i j-se
            }//end for i i-se
    for(int i=0;i<persona;i++){//cikli qe kontrollon personat me mbiemer te njejte
        for(int j=i+1;j<persona;j++){
            if( surname[i].equals(surname[j])){
               System.out.println("Personat qe kane te njejtin mbiemer jane:"+surname[i]); //afishon surnamen e personave me mbiemer te njejte
            }//end if
        }//end for i j-se
            }//end for i i-se
    
    }    //mbaron metoda main
}//mbaron klasa

Edited 4 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

first, you need to create an object, it's that object's constructor and method's you're supposed to use.
and no, you can not create methods and constructors within your main method.

songet[1]="1.Adele-Someone like you ";//songet e secilit indeks
songet[2]="2.Elton John-Sorry seems to be the hardest word ";//...
songet[3]="3.Beyonce-Halo ";//kemi lene hapsira pas cdo string songe
songet[4]="4.Rihanna-Cheers ";//..qe teafishohen ne vije te drejte ne fund
songet[5]="5.Metallica-Unforgiven ";
songet[6]="6.Bon Jovi-Runaway ";
songet[7]="7.Linkin Park-Iridescent ";
songet[8]="8.Michael Jackson-They really don't care about us";
songet[9]="9.Michael Buble-Home ";
songet[10]="10.Enrique Iglesias-Tonight ";
songet[11]="11.Mariah Carey-Hero ";
songet[12]="12.Avril Lavigne-Girlfriend ";
songet[13]="13.Nickelback-Rockstar ";
songet[14]="14.Taylor Swift-Love Story ";
songet[15]="15.Shakira-Waka Waka ";
songet[16]="16.Jenifer Lopez-I'm into you ";
songet[17]="17.Michel Telo-Ai se tu pego ";
songet[18]="18.Fly Project-Goodbye ";
songet[19]="19.Alexandra Stan-Get back ";
songet[20]="20.Mango-La rondina ";

TERRIBLE song choices :( my ears bleed just looking at it, also arrays are 0 based.

TERRIBLE song choices :( my ears bleed just looking at it, also arrays are 0 based.

there's no law forcing him to use the first index :)
as long as he doesn't try array[21], he'll be fine.

there's no law forcing him to use the first index :)
as long as he doesn't try array[21], he'll be fine.

agreed but if we're gonna help him get better...

using arrays at all is a terrible design decision... Should use a List or maybe a Set.

gotta learn to walk straight before you learn to run! :P

This article has been dead for over six months. Start a new discussion instead.