Back to bother you guys again

Q. Enter 10numbers using command line. Do the addition and print the DIV along with % . Must use a separate meathord.
A.
class Grades1
     public static void main(String[] args)
          int a=Integer.parseInt(args[0]);
          int b=Integer.parseInt(args[1]);
          int c=Integer.parseInt(args[2]);
          int d=Integer.parseInt(args[3]);
          int e=Integer.parseInt(args[4]);
          int f=Integer.parseInt(args[5]);
          int g=Integer.parseInt(args[6]);
          int h=Integer.parseInt(args[7]);
          int i=Integer.parseInt(args[8]);
          int j=Integer.parseInt(args[9]);
          int r = calmarks(a,b,c,d,e,f,g,h,i,j);
          String grade=calgrade(r);
          int z=((r*100)/1000);
          System.out.println("Your Total Marks Is :"+r+" And Div Is :"+grade);
          System.out.println("Marks In % Is :"+z);
     static int calmarks(int a,int b,int c,int d,int e,int f,int g,int h,int i,int j)
          int z=(a+b+c+d+e+f+g+h+i+j);
          return z;
     static String calgrade(int r)
                    if(r<300)     return "Fail";
          else     if(r<450)     return "Third";
          else     if(r<600)     return "Second";
          else     if(r<800)     return     "First";
          else                    return     "Star";     
}now she told me to write the code such a way that
int a=Integer.parseInt(args[0]);
          int b=Integer.parseInt(args[1]);
          int c=Integer.parseInt(args[2]);
          int d=Integer.parseInt(args[3]);
          int e=Integer.parseInt(args[4]);
          int f=Integer.parseInt(args[5]);
          int g=Integer.parseInt(args[6]);
          int h=Integer.parseInt(args[7]);
          int i=Integer.parseInt(args[8]);
          int j=Integer.parseInt(args[9]);should be in a loop so that i need not write sop much..
need help..............................
i have no idea how to do a loop in user input on command line
please give me an idea so that i can write the code my self........................

warnerja wrote:
so please guys help me by puting the code, for me to read and under standNo, that's YOUR job. YOU do the work, and ask specific questions about it if needed. The forum people are here to nudge you in the right direction, not to do lazy goof-off's homework for them.
Please ask the forum admins to rename your username to something more appropriate, like failguy .Thats so mean! Where is your Christmas spirit?
The syntax of a for loop is:
for (int i = 0; i < args.length; i++) {
  //int i is a counter variable and is declared in the first part of the loop
  //After every loop, the less than comparison is made and if i is NOT less than the args array size
  //then the loop is done.
  //i++ increments the i counter after every iteration of the loop
}Knowing this it is perfectly legal to do this in your for loop...
Integer.parseInt(args);
where the i counter is in place of a hard coded number.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

Maybe you are looking for