Results 1 to 4 of 4
  1. #1
    metallica is offline Member
    Join Date
    Jan 2014
    Posts
    1
    Rep Power
    0

    Question can anyone tell me my mistake please?

    /*This program will convert integer grades to letter grades and say how many A's, B's, C's, D's , F's do we have
    Berrehouma,Yassine
    1/31/2014
    */

    public class DSlab3
    {
    private char LetterGrades;
    private int IntegerGrades;

    //default constructor
    public DSlab3()
    {
    LetterGrades =' ';
    IntegerGrades = 0;
    }
    //Accessor
    public DSlab3 (char LG,int IG)
    {
    }
    public int getIG()
    {
    return IG;
    }
    public char getLG()
    {
    return LG;
    }

    //Mutator
    public void setIG( int newIG)
    {
    IG = newIG;
    }
    public void setLG( char newLG)
    {
    LG = newLG;
    }
    public class RandomGen
    {
    public RandomGen() {

    System.out.println("Random Number ....");
    }//end of constructor

    public static void main(String[] args)
    {
    int i, j;
    int[]ArrayRand = new int[20] ;

    for(i=0;i< 20;i++){
    j = (int)(Math.random() * 100);
    ArrayRand[i]= j;
    System.out.print("array in " + i);
    System.out.println(" is " + ArrayRand[i]);


    }// end of for
    }//end main
    }//RandomGen
    public class GradeL2I
    {
    // Instance variables
    char A,B,C,D,F;
    }
    public static char integerToLetterGrade()
    {
    int n,m,x,y,z;
    Char[]Result = new Char[20] ;//another Tab to stock the grades in letter
    for(int i = 0; i <20;i++){
    //converting the integer grades to letter grades
    if (ArrayRand[i] >= 90)
    { Result[i] = A; }
    else if (ArrayRand[i] >= 80)
    { Result[i] = B; }
    else if (ArrayRand[i] >= 70)
    { Result[i] = C; }
    else if (ArrayRand[i] >= 60)
    { Result[i] = D; }
    else
    { Result[i] = F; }
    }//end for
    for(int j = 0; j <20;j++){//a method to count the number of As
    if (Result[j] == A)
    {
    n = n+1;
    }
    }
    System.out.println("number of As is equal to " + n);


    for(int j = 0; j <20;j++){//a method to count the number of Bs
    if (Result[j] == B)
    {
    m = m+1;
    }
    }
    for(int j = 0; j <20;j++){//a method to count the number of Cs
    if (Result[j] == C)
    {
    x = x+1;
    }
    }
    for(int j = 0; j <20;j++){//a method to count the number of Ds
    if (Result[j] == D)
    {
    y = y+1;
    }
    }
    for(int j = 0; j <20;j++){//a method to count the number of Fs
    if (Result[j] == F)
    {
    z = z+1;
    }
    }
    System.out.println("The number of A's is equal to, " + n);
    System.out.print(" the number of B's is equal to, " + m);
    System.out.print(" the number of C's is equal to, " + x);
    System.out.print(" the number of C's is equal to " + y);
    System.out.print(" and the number of C's is equal to " + z);
    }
    }

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,712
    Rep Power
    5

    Default Re: can anyone tell me my mistake please?

    So what is going wrong? Besides you using variable names that are totally unreadable.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: can anyone tell me my mistake please?

    Quote Originally Posted by metallica View Post
    System.out.println("The number of A's is equal to, " + n);
    System.out.print(" the number of B's is equal to, " + m);
    System.out.print(" the number of C's is equal to, " + x);
    System.out.print(" the number of C's is equal to " + y);
    System.out.print(" and the number of C's is equal to " + z);
    Should this make sense?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,411
    Rep Power
    5

    Default Re: can anyone tell me my mistake please?

    I am assuming it doesn't compile. And due to misplaced braces, you have:

    Java Code:
    public class GradeL2I
    { 
    // Instance variables
    char A,B,C,D,F;
    }
    which is a very small useless class. But that is just the start of your problems. What are the values of A,B,C,D, and F?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Hello, I got a mistake
    By F1ke in forum New To Java
    Replies: 7
    Last Post: 09-25-2011, 08:11 PM
  2. Point my mistake
    By amzers in forum New To Java
    Replies: 11
    Last Post: 12-16-2010, 12:31 PM
  3. Help me ! identifying the mistake
    By o0oNorao0o in forum New To Java
    Replies: 6
    Last Post: 11-06-2010, 10:03 PM
  4. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 3
    Last Post: 04-29-2009, 05:26 AM
  5. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 2
    Last Post: 04-28-2009, 06:30 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
  •