Results 1 to 15 of 15
  1. #1
    wajidameen is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default Reg the earlier java program i have asked

    First thing is I am a network engineer working with cisco and second that is not my homework. I post it here just to get a basic knowledge. I was learning java online through java video tutes. So if its not a problem now can anyone write it ????

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Regardless if it's assigned by yourself or by a teacher you blatantly dumped the assignment on us and showed no work. We do not take well to this in either regard. If this doesn't suit you, you are welcome to leave and to ask these types of questions in another forum.

  3. #3
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    Listen Wajid,

    The expected way to go here is, when you post your questions, we expect to see your attempts to resolve it first.

    We don't expect people coming and passing in their [or someone else's] homework assignments to us and expect us to do it for them. That's not how it goes here.

    If you have got stuck up somewhere in your code or if your code is throwing some errors, show us the things and you can expect our help. We don't do or support spoon feeding here.

    We don't "write" the code for others, we "read" others code/attempts and provide assistance wherever needed. I hope you will understand,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  4. #4
    wajidameen is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default yes i understand this is my code

    I built this code on my basic knowledge

    1 import java.io.*;
    2 class MarksOfStudents1{
    3 int marks[]={67,89,49,95,68,80,74,59,55,57,85,92,87,50,83};
    4 for(int i=0; i<=14; i++)
    5 {
    6 System.out.println("Student marks are :"+sub_marks[i]);
    7 }
    8 void sumAverage(){
    9 int sum=0;
    10 double avg=0.0;
    11 for(int i=0;i<14;i++)
    12 {
    13 System.out .println(marks[i]);
    14 sum=sum+marks[i];
    15 avg=sum/15;
    16 System.out.println("marks of students= " +sum);
    17 System.out.println("avg");
    18 }
    19 }
    20 void maximumMminimum(){
    21 System.out.println("Minimum value="+getMinValue(marks));
    22 System.out.println("Maximum value=" + get max value (marks));
    23 }
    24 void sorting(){
    25 for (int i=0;i<14;i++){
    26 for (int j=i+1; j<15; j++){
    27 if(marks[i]> marks[j]){
    28 int x,y;
    29 x=marks[i];
    30 y=marks[j];
    31 marks[i]=y;
    32 marks[j]=x;
    33 }
    34 }
    35 }
    36 System.out.println("Array after sorting in ascending order");
    37 System.out.println();
    38 for (int i=0;i<14;i++)
    39 System.out.println(marks[i]);
    40 }
    41 public static void main(String args[]){
    42 MarksOfStudents ms =new MarksOfStudents();
    43 }
    44 }
    Last edited by wajidameen; 01-12-2011 at 06:17 AM.

  5. #5
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    See, you understood that! That's the way :)

    Now one more thing, whenever you post your code, use the code tags. For more details refer here: Code Tags

    Now, coming back to your code, what is the problem you are facing in this? Errors? Exceptions? Something else?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  6. #6
    wajidameen is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    47 errors found:
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: ')' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: <identifier> expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: ';' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: <identifier> expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: <identifier> expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 4]
    Error: C:\Users\Home\MarksOfStudents1.java:4: <identifier> expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 5]
    Error: C:\Users\Home\MarksOfStudents1.java:5: ';' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: ';' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: invalid method declaration; return type required
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: ')' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: ';' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: illegal start of type
    File: C:\Users\Home\MarksOfStudents1.java [line: 6]
    Error: C:\Users\Home\MarksOfStudents1.java:6: ';' expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 8]
    Error: C:\Users\Home\MarksOfStudents1.java:8: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 10]
    Error: C:\Users\Home\MarksOfStudents1.java:10: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 11]
    Error: C:\Users\Home\MarksOfStudents1.java:11: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 11]
    Error: C:\Users\Home\MarksOfStudents1.java:11: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 11]
    Error: C:\Users\Home\MarksOfStudents1.java:11: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 14]
    Error: C:\Users\Home\MarksOfStudents1.java:14: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 15]
    Error: C:\Users\Home\MarksOfStudents1.java:15: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 16]
    Error: C:\Users\Home\MarksOfStudents1.java:16: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 17]
    Error: C:\Users\Home\MarksOfStudents1.java:17: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 18]
    Error: C:\Users\Home\MarksOfStudents1.java:18: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 22]
    Error: C:\Users\Home\MarksOfStudents1.java:22: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 23]
    Error: C:\Users\Home\MarksOfStudents1.java:23: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 25]
    Error: C:\Users\Home\MarksOfStudents1.java:25: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 25]
    Error: C:\Users\Home\MarksOfStudents1.java:25: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 26]
    Error: C:\Users\Home\MarksOfStudents1.java:26: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 26]
    Error: C:\Users\Home\MarksOfStudents1.java:26: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 29]
    Error: C:\Users\Home\MarksOfStudents1.java:29: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 30]
    Error: C:\Users\Home\MarksOfStudents1.java:30: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 31]
    Error: C:\Users\Home\MarksOfStudents1.java:31: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 32]
    Error: C:\Users\Home\MarksOfStudents1.java:32: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 33]
    Error: C:\Users\Home\MarksOfStudents1.java:33: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 37]
    Error: C:\Users\Home\MarksOfStudents1.java:37: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 38]
    Error: C:\Users\Home\MarksOfStudents1.java:38: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 38]
    Error: C:\Users\Home\MarksOfStudents1.java:38: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 38]
    Error: C:\Users\Home\MarksOfStudents1.java:38: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 40]
    Error: C:\Users\Home\MarksOfStudents1.java:40: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 41]
    Error: C:\Users\Home\MarksOfStudents1.java:41: class, interface, or enum expected
    File: C:\Users\Home\MarksOfStudents1.java [line: 43]
    Error: C:\Users\Home\MarksOfStudents1.java:43: class, interface, or enum expected

  7. #7
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    Thats what was expected anyways.

    I had a look at your code and frankly speaking it's horrible. Sorry for this!

    But you have made so many mistakes,

    1) You have used method names, which doesn't exist.
    2) You are putting your code directly in your class file instead of methods.
    3) You are declaring your variables with one name and trying to access them with some other name.
    4) You have declared methods, but you are not calling them from anywhere. So you cant expect them to get into the picture.
    5) You haven't even created your class object in the right way.
    ... and so many other things.

    I would seriously advice you to go for some good java study; either some good online documentation or some good java book. Do this before attempting to code java, as that would make your concepts good and you will avoid any such mistakes.

    Your code is out of scope for any corrections, as the things themselves are not in right place. I hope you will understand,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  8. #8
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    A quick bit of advice, try this:
    Java Code:
    class AClass
    {
      double average(arg){...}
      int max(arg){...}
      int min(arg){...}
      void sort(arg){...}
      public static void main(String[] args)
      {
        int[] x = new int[15];
        System.out.println(average(x));
        System.out.println(max(x));
        System.out.println(min(x));
        sort(x);
        for(int i = 0; i < x.length; i++)
        {
            System.out.print(x[i]);
         }
         System.out.println();
       }
    }
    The functions max, min, average, and sort all take an array of something as an argument, in this case int[].

    The only method that really takes a bit of thinking is the sort method. The rest you pretty much have completed, the code seems a little messy, make sure spelling is correct, all statements end with a ;, and so on.

    also, as for the sort, you can use built in sorting, to read about it, follow the link:
    Java: Sorting Arrays


    The general structure of a class should generally be as follows:
    Java Code:
    class SomeClass
    {
      classvar1;
      classvar2;
      ...
      classvarn;
      method1;
      method2;
      ...
      methodn;
    
      public static void main(String[] args)
      {
        call methods;
        manipulate vars and methods;
        create class instances;
        ...
      }
    }
    This is however very general, but it's all more than enough to achieve what you want.
    Hope this helps!
    Last edited by sunde887; 01-12-2011 at 06:43 AM.

  9. #9
    wajidameen is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    am not a java programmer but a network associate
    anyways thanx for all your efforts.

    Can anyone complete it now?

  10. #10
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    Quote Originally Posted by wajidameen View Post
    Can anyone complete it now?
    I think this has been covered and conveyed previously.

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,762
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by wajidameen View Post
    Can anyone complete it now?
    vWorker.com: More capable, accountable and affordable. Guaranteed.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by goldest View Post
    I think this has been covered and conveyed previously.
    He's a slow learner on this point.

  13. #13
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    There just aren't words to...

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    Quite.
    They're trying to learn Java online, and in order to do so they are asking someone else to do the code for them.

  15. #15
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Oh hey, while I'm thinking of it, could you guys port Doom 3 to java for me? KThanxBai.

Similar Threads

  1. Replies: 4
    Last Post: 07-30-2010, 01:25 PM
  2. Replies: 1
    Last Post: 04-01-2010, 06:14 PM
  3. Earlier date
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 3
    Last Post: 02-07-2010, 07:04 PM
  4. Replies: 0
    Last Post: 04-04-2008, 03:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •