Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class lesson1{
- public static void main(String[] args) {
- int a,b,c;
- System.out.println("enter two integer");
- Scanner sn = new Scanner(System.in);
- a= sn.nextInt();
- b= sn.nextInt();
- c=a+b;
- System.out.println("the sum of the two given integer is: "+c);
- prime();
- salary();
- factorial();
- weird();
- pali();12
- Avagdrow();
- calculator();
- }
- public static void prime()///////CODE FOR PRIME NUMBERS//////////
- {
- int n;
- Scanner ss = new Scanner(System.in);
- System.out.println("enter a integer to know if it is prime number or not ");
- n =ss.nextInt();
- if (n%2==0) {
- System.out.println("the integer is prime ");
- } else {
- System.out.println("the Interger is !prime ");
- }
- }
- public static void salary()/////////CODE FOR BASIC SALARY //////////
- {
- double sal;
- double epf,hra,da,ta,netsal;
- System.out.println("enter your current salary");
- Scanner sc = new Scanner(System.in);
- sal=sc.nextDouble();
- hra=(sal*100/10);
- epf=(sal*100/25);
- ta=(sal*100/50);
- da=(sal*100/12);
- netsal=(hra+ta-da+epf);
- System.out.println("the net salary is:"+netsal);
- }
- ////////////CODE FOR FACTORIAL OF A NUMBER///////////
- /public static void factorial()
- {
- int n,i;
- int fac = 1;
- Scanner sn =new Scanner(System.in);
- System.out.println("enter a integer for Factorial");
- n=sn.nextInt();
- for(i=1 ;i<=n; ++i)
- {
- fac*=i;
- }
- System.out.println("factorial: "+fac);
- }
- /////////////CODE FOR TWISTING DIGITS OF THE NUMBER///////////
- public static void weird()
- {
- int num,rem;
- int e=0 , o=0;
- Scanner scc = new Scanner(System.in);
- System.out.println("Enter an integer ");
- num = scc.nextInt();
- while(num>0){
- rem=num%10;
- if(rem%2==0)
- {
- e++;
- }
- else{
- o++;
- }
- num=num/10;
- }
- System.out.println("H"+e +o);
- }
- //////CODE FOR PALINDROME NUMBER///////////////
- public static void pali()
- {
- int num,rem,k=0;
- System.out.println("enter an integer");
- Scanner scc = new Scanner(System.in);
- num=scc.nextInt();
- int y = num;
- while(num>0){
- rem =num %10;
- num =num /10;
- k = (k *10)+rem;
- }
- if (k==y) {
- System.out.println("the is palindrome");
- } else {
- System.out.println("the is ! palindrome");
- }
- }
- public static void Avagdrow()////CODE FOR AVAGADROW NUMBER/////////
- {
- int num,k,rem,A=0;
- Scanner scc = new Scanner(System.in);
- System.out.println("Enter an interger ");
- num=scc.nextInt();
- int y = num;
- while(num>0)
- {
- rem=num%10;
- num=num/10;
- A=(rem*rem*rem)+A;
- }
- if (A==y) {
- System.out.println("this is a Avagadrow number");
- } else {
- System.out.println("this ! a Avagadrow number");
- }
- }
- public static long calculator()///////CODE FOR THE CALCULATOR //////////
- {
- int num1, num2, choice;
- Scanner sc = new Scanner(System.in);
- boolean check = false;
- do{
- System.out.println("Enter two integers: ");
- num1 = sc.nextInt();
- num2 = sc.nextInt();
- System.out.println("1: Addition");
- System.out.println("2: Subtract");
- System.out.println("4: Divide");
- System.out.println("0: Quit");
- System.out.println("Enter Choice: ");
- choice = sc.nextInt();
- if (choice == 1){
- System.out.println(num1 + num2);
- }else if (choice == 2){
- System.out.println(num1 - num2);
- }else if (choice == 3){
- System.out.println(num1 * num2);
- }else if (choice == 4){
- System.out.println(num1 / num2);
- }else if (choice == 0)
- {
- System.out.println("This way to the exit.");
- System.exit(0);
- }else
- {
- System.out.println("Error, entered wrong number.");
- }
- while (check==true);
- System.out.print("Finished.");
- }while (choice >= 5);
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment