Results 1 to 6 of 6

Thread: School works?

  1. #1
    D-X69's Avatar
    D-X69 is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default School works?

    Here's a link to the PDF of my homework:
    Fall2011Midterm.pdf

    My mid term's over. And I was having trouble getting these following questions to compile and work:
    - 2(c) (TransformGrades.java)
    - 4(b) (NormalGenerate.java)
    - 6(b), (c) (FindMinMax.java)

    P.S.: I'm a VIM user.

    Anyway, please help me out I need to get these three questions to work and handed in to get some additional marks in my midterm as no one seems to be able to get these questions right in my class.

    Tim

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: School works?

    (I've closed the duplicate of this thread)

    I need to get these three questions to work
    It might help if you could clarify this a bit.

    Do you have code that does not compile? If so, what is the code and what are the compiler messages? If you post them maybe someone help explain what they are getting at.

    If it's a matter of the questions asking you to write code, what have you written? If it does compile but does not do at runtime what you expect or intend, say what it does do (including any runtime errors) and describe your intentions or expectations.

    If it's a question of how you start, common advice is for you to think about the problem and come up with a way in which *you* rather than a computer might perform the task that has been posed. Try and develop a "recipe" that is both precise and comprehensive. Be able to express that recipe lucidly in natural language before you begin to write code.

    -----

    Many here won't go to the trouble of downloading files and figuring out what a problem *is*. There is an expectation that you will do this.
    Last edited by pbrockway2; 11-20-2011 at 07:57 AM.

  3. #3
    D-X69's Avatar
    D-X69 is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: School works?

    Okay, I got the first one to work with the help from one of my seniors. And I successfully got it to work. Here's the code:

    public class TransformGrade
    {
    public static void main(String[] args)
    {
    int c = 0;
    int b = 0;
    int a = 0;

    for(int i = 0 ;i<args.length ;i++)
    {
    double grade = Double.parseDouble(args[i]);

    if (grade<60) c++;

    else if (grade>59 && grade<80) b++;

    else a++;
    }

    System.out.print("C : ");

    for (int j = c ;j>0 ;j--)
    {
    System.out.print("*");
    }
    System.out.println();

    System.out.print("B : ");

    for (int k = b ;k>0 ;k--)
    {
    System.out.print("*");
    }
    System.out.println();

    System.out.print("A : ");

    for (int l = a ;l>0 ;l--)
    {
    System.out.print("*");
    }
    System.out.println();
    }
    }
    However I don't get this part:
    for (int j = c ;j>0 ;j--)
    {
    System.out.print("*");
    }
    System.out.println();

    System.out.print("B : ");

    for (int k = b ;k>0 ;k--)
    {
    System.out.print("*");
    }
    System.out.println();

    System.out.print("A : ");

    for (int l = a ;l>0 ;l--)
    {
    System.out.print("*");
    }
    System.out.println();
    }
    Mind doing some explainations? Thanks.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default Re: School works?

    Why don't you ask the person that wrote it?

  5. #5
    D-X69's Avatar
    D-X69 is offline Member
    Join Date
    Nov 2011
    Posts
    6
    Rep Power
    0

    Default Re: School works?

    Quote Originally Posted by Tolls View Post
    Why don't you ask the person that wrote it?
    Because he cannot explain it in english. He can only explain it in chinese. which is why i asked here. and my chinese is not that good.

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

Similar Threads

  1. School project help!
    By Addez in forum Advanced Java
    Replies: 5
    Last Post: 09-17-2010, 10:37 PM
  2. Need help with school project!
    By jaxxx in forum New To Java
    Replies: 5
    Last Post: 03-25-2010, 08:55 PM
  3. Need help with school assignment
    By sljkbn in forum New To Java
    Replies: 6
    Last Post: 10-28-2009, 01:07 PM
  4. Need help with school work
    By ccfdet in forum New To Java
    Replies: 3
    Last Post: 08-29-2009, 07:14 PM
  5. school project help
    By justin8790 in forum New To Java
    Replies: 5
    Last Post: 03-22-2009, 09:54 AM

Posting Permissions

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