How to determine the number divisible by 7 in java
Monday, March 16, 2009
import java.io.*; class bbb { public static void main(String args[])throws IOException { int a,b,m=0,sum=0; BufferedReader ob=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter your first & last number"); a=Integer.parseInt(ob.readLine()); b=Integer.parseInt(ob.readLine()); System.out.println(); for(int i=a;i<=b;i++) { if(i%7==0) { sum=sum+i; m=m+1; for(int j=m;j<=m;j++) { System.out.printf("the number[%2d] diviseble by 7:",j); System.out.print(i); } System.out.println(); } } } }
0 comments:
Post a Comment