TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Calculate natural numbers that are divide by 7 & 8 using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
600
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssvnat.rar
//NATURALS NUMBERS THAT ARE DIVISIBLE BY 7 & 8
import
java.io.*;
class
ssvnat
{
public
static
void
main(String arg[])
throws
IOException
{
int
i,a,b,s=
0
,start,end;
BufferedReader br=
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.println(
"\n\t\t*** NATURALS NUMBERS THAT ARE DIVISIBLE BY 7 & 8 *** \n"
);
System.out.print(
"Enter the number will be started : "
);
start=Integer.parseInt(br.readLine());
System.out.print(
"Enter the number to be end : "
);
end=Integer.parseInt(br.readLine());
for
(i=start;i<=end;i++)
{
a=i%
7
;
b=i%
8
;
if
((a==
0
)&&(b==
0
))
{
System.out.print(
"\t"
+ i);
s=s+i;
}
}
System.out.print(
"\n\nThe Sum of Numbers that are divisible by 7 and 8 : "
+ s);
System.out.println();
}
}
Java