NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

COMPUTER PROGRAMS
No.1
import java.util.Scanner;
//to input 2 integers and if either is 0 to exit or to divide larger by smaller number.
class pg165_13
{
public static void main ()
{
Scanner sc = new Scanner (System.in);
int x,y,q ;
System.out.println ("Enter any 2 integers : ");
x = sc.nextInt();
y = sc.nextInt();
if (x==0 || y==0)
{
System.out.println ("Invalid entry");
}
else if (x>=y)
{
q = x/y;
System.out.println ("The quotient of "+x+ "/" +y+ " is "+q);
}
else if (y>=x)
{
q = y/x;
System.out.println ("The quotient of "+y+ "/" +x+ " is "+q);
}
}
}
star 1

No.2
//to input three integers and check whether all the three integers are different from each other or not
import java.util.Scanner;
class prg_12
{
static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter three integers");
int num1 = sc.nextInt();
int num2 = sc.nextInt();
int num3 = sc.nextInt();
if (num1==num2&&num1==num3&&num2==num3)
{
System.out.println("All the three numbers are the same");
}
else
{
System.out.println("All the three numbers are unique(different)");
}
}
}
star 1

No.3
//to input an integer and check whether the number is a 2digit or a 3digit number
import java.util.Scanner;
class prg_10
{
static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter an integer");
int num = sc.nextInt();
if(num>9&&num<100)
{
System.out.println("The number is a two digit number");
}
else if(num>99&&num<1000)
{
System.out.println("The number is a three digit number");
}
else
{
System.out.println("The number is not a 3 digit number or a three digit number");
}
}
}

No.4
import java.util.Scanner;
//to check whether a three digit number is divisible by 3 or not
class pg165_9
{
public static void main ()
{
Scanner sc = new Scanner (System.in);
int x;
System.out.println ("Enter an integer value : ");
x = sc.nextInt();
if (x>=100 && x<=999 || x<=-100 && x>=-999)
{
System.out.println (x+" is a 3-digit number");
if (x%3==0)
System.out.println (x+" is divisible by 3");
else
System.out.println (x+" is not divisible by 3");
}
else
{
System.out.println (x+" is not a 3-digit number");
}
}
}

No.5
//to check whether an integer is a two digit number or not
import java.util.Scanner;
class prg_8
{
static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter an integer");
int num = sc.nextInt();
if(num>=10 && num<=99 || num>=-99 && num<=-10)
{
System.out.println("It is a 2-digit number");
}
else
{
System.out.println("Not a 2-digit number");
}
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.