i need help writing a program using array. ASAP! - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42

Thread: i need help writing a program using array. ASAP!

  1. #16
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    okY so i got the errors down to 5.. here the new code so far... i forgot to give a option for the user to enter grade..

    import java.util.Scanner;
    public class Q7_A_112532 {
    public static void main(System[] args){
    Scanner input = new Scanner(System.in);
    int num = 0;
    int excellentstudent;
    excellentstudent = 0;
    double percentage = 0;
    int grade;

    System.out.print("enter the total number of students: ");
    num = input.nextInt();
    int i;
    int studentarray;
    studentarray = new.int[num];
    {for (i = 0; i < studentarray.length, i++ )};
    sum = sum + arr[num];

    System.out.print("Enter the grade of the student: ");
    grade = input.nextInt();

    if (grade >= 90 )
    gradecount ++;

    percentage = count * 100 / num;

    System.out.printf("The percentage f excellent student is : %.1f", + percentage);


    }

    }

  2. #17
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: i need help writing a program using array. ASAP!

    um i thought u would need to calculate the percentage of excellent students... thats why... u think i should remove that part?
    But you aren't using it anywhere. But I wouldn't worry about that at the moment, the first thing is to get your code compiling.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #18
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: i need help writing a program using array. ASAP!

    Please use code tags when posting code.

    Format your code properly so the curly braces and indents are all consistently aligned, this will help highlight at least one problem.

    If I have to keep asking you to post error message etc this will take all night and I don't have all night. If there are 5 errors, post the messages.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  4. #19
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    okay i got all the errors i could fixed... but still have four left!

    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:25: error: <identifier> expected
    studentarray = new.int[num];
    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:25: error: <identifier> expected
    studentarray = new.int[num];
    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:26: error: illegal start of expression
    {for (i = 0; i < studentarray.length; i++ )};
    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:42: error: reached end of file while parsing
    }
    4 errors


    i am so sorry for bothering you.... but at the current moment u are the only help i have!

  5. #20
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: i need help writing a program using array. ASAP!

    i am so sorry for bothering you..
    Don't worry, I'm just concerned we don't have enough time.

    The first two errors I have already explained in an earlier post.
    The 3rd error is because the for statement shouldn't be wrapped in curly braces
    The 4th is because you probably don't have the same number of opening and closing curly braces hence my earlier comment about formatting your code properly.
    Last edited by keang; December 18th, 2012 at 02:32 PM.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  6. #21
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    i think the atempt of fixing the last four errors i have messed it all up all over...i bet u might be thinking i am like a crazy person or something.... but i think its slowly getting over m,y head.... now i think i am screwed it big time... coz in the middle i was working on another program... which was fine... but now donno what to do!

    am, trying to get back to where it was..

  7. #22
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    okay wait i think i got everything back.. lemme work on ur suggestion and i will get back to you

  8. #23
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: i need help writing a program using array. ASAP!

    Fixing one error can often make more errors appear, it doesn't necessarily mean you done something wrong.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  9. #24
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    yeah never thought of that..am gonna keep that in mind... okay so am down to 3 errors..

  10. #25
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    okay so i removed the curly brace from one of em... but there is a new error in it..


    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:26: error: <identifier> expected
    studentarray = new.int[num];
    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:26: error: <identifier> expected
    studentarray = new.int[num];
    C:\Users\Al Doctor\Documents\NetBeansProjects\HafsaShahab_112532\src\Q7_A_112532.java:48: error: class, interface, or enum expected
    }
    3 errors

  11. #26
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    okay so got ride of the last error... but the other two are still pending... can re-explain what i have to do to fix it.

  12. #27
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: i need help writing a program using array. ASAP!

    Without seeing the current code it's hard to say exactly but you certainly shouldn't have a '.' in 'new.int' and you probably haven't declared studentarray
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  13. #28
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    import java.util.Scanner;
    public class Q5_112532 {
    public static void main(String[] args){
    Scanner input = new Scanner(System.in);
    int integer;

    System.out.print("Enter an integer less then 2147483648: ");
    integer = input.nextInt();

    int sum = 0;

    while (integer != 0){
    sum += integer % 10;

    integer /= 10;
    }
    System.out.print("the sum of digits of integers is ");

    if (sum % 2 == 0){
    System.out.println("even!");
    }
    else
    {
    System.out.println("odd!");
    }




    }
    }
    SO THIS WHAT I HAVE GOTTEN AFTER ALL THAT!!

  14. #29
    Join Date
    Dec 2012
    Posts
    21

    Re: i need help writing a program using array. ASAP!

    WOOPS DORRY WRONG PROGRAM!!

    import java.util.Scanner;
    public class Q7_A_112532 {

    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in);
    int num = 0;
    double percentage = 0;
    int grade;

    System.out.print("Enter the number of students");
    num = input.nextInt();


    int sum;
    int studentarray;

    studentarray = new.int[num];
    for (num = o; num < studentarray.length; num ++);
    sum = sum + arr[num];

    System.out.print("enter the grade of the student: ");
    grade = input.nextInt();

    if ( grade >= 90)
    gradecount ++;

    percentage = gradecount * 100 / num;

    System.out.printf("The percentage of excelent students: %.1f", +percentage);
    }







    }

  15. #30
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: i need help writing a program using array. ASAP!

    What about error messages and you still have a '.' in 'new.int'
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center