Computer Science, asked by anjaneyabk2, 3 months ago

WRITE A PROGRAM TO ACEPT A NUMBER AND CHECK WHETHER THE NUMBER IS DIVISIBLE BY 3 AS WELL AS 5 OTHERWISE DECIDE
IS THE NUMBER DIVISIBLE BY 3 AND NOT BY 5

Answers

Answered by deepakkumar9254
4

Steps -

Step 1 - Start.

Step 2 - Accept a number.

Step 3- Check whether it is divisible by 3 and 5 both. If yes print "the number is divisible by 3 and 5 both" and end the program. If not jump to step 4.

Step 4 - Check whether it is divisible by 3. If yes print "the number is divisible by 3" and end the program. If not jump to step 5.

Step 5 - Check whether it is divisible by 5. If yes print "the number is divisible by 5" and end the program. If not jump to step 6.

Step 6 - Print "the number is not divisible by 3 and 5 both" and end the program.

Step 7 - End.

Program (Using Java):-

import java.util.Scanner;

class d

{

   public static void main(String args[])

   {

       System.out.println("Enter a number");

       int n;

       Scanner sc=new Scanner(System.in);

       n = sc.nextInt();        

       if(n%3 == 0 && n%5 == 0)

       {

          System.out.println("The number is divisible by 3 and 5 both");

       }

       else if(n%3 == 0 && n%5 != 0)

       {

          System.out.println("The number is divisible by 3 only");

       }

       else if(n%5 == 0 && n%3 != 0)

       {

          System.out.println("The number is divisible by 5 only");

       }

       else  

       {

           System.out.println("The number is not divisible by 3 and 5");

       }

   }

}  

Output:- is in the attachment.

Glossary :-

\begin{array}{| c | c | c |}\cline{1-3} \bf Variable & \bf Type & \bf Description \\ \cline{1-3} n &\sf int & to\:\:store\:\:the\:\:number\\ \cline{1-3}\end{array}

Attachments:
Answered by gameingmahakal129
0

Answer:

dyowueirbbgeheb

Explanation:

qghwhwhehejevge

Similar questions