Please answer the following question DO PARTS CEFGH correctl
Please answer the following question (DO PARTS C,E,F,G,H) correctly and completely.
****IMPORTANT***:PLEASE ONLY COMPLETE PARTS C,E,F,G and H COMPLETELY AND CORRECTLY
Solution
C,E,F,G,H
(C) There are total number of 4536 distinct digits present between 1000 and 9999 inclusive.
(E) There are total of 2829 number present between 1000 and 9999 inclusive divisible by 5 or 7
(F) There are total of 8743 number present between 1000 and 9999 inclusive not divisible by 5 or 7
(G) 1543 number present between 1000 and 9999 inclusive that are divisible by 5 but not by 7
(H) 257 number present between 1000 and 9999 inclusive divisible by 5 and 7
to check the correctness you can run following java codes
For (c)
class ex1
{
public static void main(String ar[])
{
int count=0;
for(int no=1000;no<=9999;no++)
{
int dg1=no%10;
int dg2=(no/10)%10;
int dg3=(no/100)%10;
int dg4=no/1000;
if(dg1!=dg2 && dg1!=dg3 && dg1!=dg4 && dg2!=dg3 &&dg2!=dg4 && dg3!=dg4)
{
count++;
System.out.println(\" \"+no);
}
}
System.out.println(\"\ \"+count);
}
}
For (E)
class ex2java
{
public static void main(String ar[])
{
int count=0;
for(int no=1000;no<=9999;no++)
{
if(no%5==0 || no%7==0)
{
count++;
System.out.println(\" \"+no);
}
}
System.out.println(\"\ \"+count);
}
}
For (F)
class ex3java
{
public static void main(String ar[])
{
int count=0;
for(int no=1000;no<=9999;no++)
{
if(no%5!=0 || no%7!=0)
{
count++;
System.out.println(\" \"+no);
}
}
System.out.println(\"\ \"+count);
}
}
for G
class ex4java
{
public static void main(String ar[])
{
int count=0;
for(int no=1000;no<=9999;no++)
{
if(no%5==0 && no%7!=0)
{
count++;
System.out.println(\" \"+no);
}
}
System.out.println(\"\ \"+count);
}
}
//For H
class ex5java
{
public static void main(String ar[])
{
int count=0;
for(int no=1000;no<=9999;no++)
{
if(no%5==0 && no%7==0)
{
count++;
System.out.println(\" \"+no);
}
}
System.out.println(\"\ \"+count);
}
}

