Results 1 to 5 of 5
  1. #1
    MSs.Java is offline Member
    Join Date
    Apr 2010
    Posts
    6
    Rep Power
    0

    Question what the wrong in my program ><

    hi every one :)
    I am still having begun in Java ;)

    and i hav this sheet I wrote the program But there are mis-outputs :confused::confused:

    That is the question
    Write a program to read N integers , then find and print the following :
    1- Count numbers between 3 and 10.
    2- Count numbers divisible by 5.
    3- Count numbers divisible by 10.
    4- Largest number.
    and this my answers:D








    import java.util.*;
    public class try1
    {
    public static void main (String []args )
    {
    Scanner console=new Scanner(System.in);

    int n1=0,n=0 , n2 =0,n3=0,count ;
    double larg = 0, small=0,divi, max ;



    System.out.println("entar N intgar number " );
    n1 = console.nextInt();

    max = n1 ;




    for ( n1= 10 ; n1>3 && n1<10 ; n++);
    {
    n1 = console.nextInt();



    System.out.println("1- Num between 3 and 10 :" +" "+ "count"+ " " + n);
    }





    if (n1 %5 == 0 )
    {
    n2 ++ ;
    System.out.println(" Num 5-divisibles :Count =" + " " + n2 );

    }




    if (n1 %10 == 0 )
    {
    n3 ++ ;
    System.out.println(" Num 10 -divisibles :Count =" + " " + n3 );

    }








    for ( count = 1 ; count <10 ; count++);
    {
    n1 = console.nextInt();

    if (n1 >max)
    max= n1 ;
    else
    max = max ;
    System.out.println(" the large number " + " " + max );



    }



    }
    }



    can any one help me :o

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Id say you should use a List to store the numbers. Then you need to have a few methods to calculate the values.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    7

    Default

    Please use code tags to show your code, it's more readable.
    Swastik

  4. #4
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Since you read in N integers, and you input N, an array would suffice, no need to go for Lists.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Quote Originally Posted by m00nchile View Post
    Since you read in N integers, and you input N, an array would suffice, no need to go for Lists.
    As long as you know what N is. The task doesn't mention asking for N.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Wrong Order in Program Run
    By HeatR216 in forum New To Java
    Replies: 0
    Last Post: 03-25-2010, 09:41 PM
  2. Payroll Program exits at wrong time
    By jsand2 in forum Java Applets
    Replies: 13
    Last Post: 01-26-2009, 04:10 AM
  3. What's wrong in my program...?
    By Annatar in forum Java Software
    Replies: 3
    Last Post: 10-31-2008, 07:03 AM
  4. Simple Addition Program Outputting Wrong Value
    By carlodelmundo in forum New To Java
    Replies: 4
    Last Post: 08-05-2008, 04:37 AM
  5. what is wrong with this program ?
    By Poor Bee in forum New To Java
    Replies: 1
    Last Post: 05-07-2008, 08:23 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
  •