#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Can someone help me with this code and its error? im java beginner.


    i got some errors,,,
    can yu spot me where i made mistake,,!
    the java coding is

    import java.util.Scanner;
    class student
    {
    public static void main(String a[])
    {
    int m1,m2,total;
    float avg;
    Scanner s=new Scanner(System.in);
    System.out.println("enter ram mark");
    m1=s.intnext();
    m2=s.intnext();
    total=(m1+m2);
    float avg=((m1+m2)/2);
    System.out.println("average mark of ram is" +avg+ "!");
    }
    }


    thanq,,!
    [IMG]imag[/IMG]
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,576
    Rep Power
    1906
    Did you get any error message? please post it.
    Did not get the expected result? please tell what you got and what you expected.

    When posting code, please use code tags. Read the sticky posts for more information.

    you have defined avg (as float) twice

IMN logo majestic logo threadwatch logo seochat tools logo