Computer Science, asked by sy6755915, 8 months ago

• to check whether the accepted integer is multiple of 3 or multiple of 7 code in javascript

Answers

Answered by vlbhartiya
2

Answer:

import java.util.*;

class Multiple{

void main(){

Scanner sc = new Scanner (System.in);

System.out.println(“Enter an integer”);

int n = sc.nextInt();

if(n%3==0||n%7==0){

System.out.print(“Yes”);

}

else System.out.println(“no”)

}

}

Explanation:

Answered by AskewTronics
3

Below are the code in java script and HTML for the above problem

Explanation:

<HTML>  <! ––HTML open tag––>

<HEAD>  <! –– HEAD open tag ––>

<TITLE>  <! –– TITLE open tag ––>

Programs to check multiple of 3  and 7

</TITLE>  <! –– TITLE Close tag ––>

<! –– Java script starts ––>

<! –– SCRIPT WORD WRITTEN IN <> SYMBOLS ––>

function CHECK()  

{  

 var input=document.getElementById("input").value;  // to take the inputs from input box.

  if(input%3==0) // to check the multiple of 3

document.write("It is a multiple of 3");  

else if(input%7==0)  // to check the multiple of 7

document.write("It is a multiple of 7");  

 else  //else block

  document.write("It is a neither multiple of 3 nor multiple of 7");

}

<! –– SCRIPT WORD WRITTEN IN </> SYMBOLS ––>

<! –– Java scripts ends ––>

</HEAD>  <! –– HEAD close tag––>

<BODY>  <! –– BODY open tag  ––>

<INPUT TYPE="text" id="input">  <! –– Input box ––>

<button ONCLICK=CHECK();>SUBMIT</button>  <! –– Submit button ––>

</BODY>  <! –– BODY close tag  ––>

</HTML>  <! –– HTML close tag ––>

Output:

  • If the user inputs 3, then it will prints that "It is a multiple of 3."
  • If the user inputs 7, then it will prints "It is a multiple of 7".

Code Explanation:

  • The above HTML code has a text box and buttons. The text box is used to take the value from the user and when the user clicks the button that value is passed to the script function.
  • Then the javascript code will check that the inputted value is multiple of 3 or multiple of 7 and print the case which is satisfied by the value.

Learn More:

  • Java script: https://brainly.in/question/6445484

Similar questions