0% found this document useful (0 votes)
3 views2 pages

Java Program

The document contains two Java programs. The first program checks if a number is prime by counting its divisors, while the second program performs basic arithmetic operations based on user input. Both programs utilize the Scanner class for user interaction.

Uploaded by

eaglepro4320
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Program

The document contains two Java programs. The first program checks if a number is prime by counting its divisors, while the second program performs basic arithmetic operations based on user input. Both programs utilize the Scanner class for user interaction.

Uploaded by

eaglepro4320
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

Scanner;
class Primenumber
{
public static void main(String[] args)
{
int i=1,n,count=0;
Scanner Scan=new Scanner([Link]);
[Link]("Enter the number");
n=[Link]();
while(i<=n)
{
if(n%i==0)
count++;
i++;
}

if (count==2)
[Link]("The number is prime");

else
[Link]("the number is not
prime");

}
import [Link];
class SimpleCalculation
{
public static void main(String[] args)
{
int choice,a,b,c;
Scanner Scan=new Scanner([Link]);
[Link]("Enter the choice");
choice=[Link]();
[Link]("Enter the two number");
a=[Link]();
b=[Link]();
switch(choice)
{
case 1:c=a+b;
[Link]("The addition of c is "+c);
break;
case 2:c=a-b;
[Link]("The substraction of c is
"+c);
break;
case 3:c=a*b;
[Link]("The multiplicaton of c is
"+c);
break;
case 4:c=a/b;
[Link]("The division of c is "+c);
break;
}

You might also like