Results 1 to 5 of 5
Thread: what the wrong in my program ><
- 05-03-2010, 11:53 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 6
- Rep Power
- 0
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
and this my answers:DWrite 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.
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
- 05-03-2010, 12:01 PM #2
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
- 05-03-2010, 12:03 PM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Please use code tags to show your code, it's more readable.
Swastik
- 05-03-2010, 12:43 PM #4
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 4
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.
- 05-03-2010, 01:28 PM #5
Similar Threads
-
Wrong Order in Program Run
By HeatR216 in forum New To JavaReplies: 0Last Post: 03-25-2010, 08:41 PM -
Payroll Program exits at wrong time
By jsand2 in forum Java AppletsReplies: 13Last Post: 01-26-2009, 03:10 AM -
What's wrong in my program...?
By Annatar in forum Java SoftwareReplies: 3Last Post: 10-31-2008, 06:03 AM -
Simple Addition Program Outputting Wrong Value
By carlodelmundo in forum New To JavaReplies: 4Last Post: 08-05-2008, 03:37 AM -
what is wrong with this program ?
By Poor Bee in forum New To JavaReplies: 1Last Post: 05-07-2008, 07:23 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks