10 comments:

  1. import java.util.Scanner;

    class Test{

    public static void clearscreen(){
    for(int clear = 0; clear < 100; clear++)
    {
    System.out.println("\b") ;
    }
    }

    public static void main(String ar[])
    {

    Scanner sc=new Scanner(System.in);
    String continuee;
    int menuinput,num,rem=0;
    System.out.println("Select any option.");
    System.out.println("1.Reverse Number");
    System.out.println("2.Sum of all Digits");
    System.out.println("3.Number of Digits");
    System.out.println("4.Product of all Digits");
    System.out.println("5.Biggest Digit");
    System.out.println("6.Smallest Digit");
    menuinput=sc.nextInt();

    switch(menuinput)
    {
    case 1:
    clearscreen();
    int rev=0;
    System.out.println("Reverse Number");
    System.out.println("Enter Number");
    num=sc.nextInt();
    while(num>0){
    rem=num%10;
    rev=(rev*10)+rem;
    num/=10;
    }
    System.out.println("Reversed Number = "+rev);
    break;

    case 2:
    clearscreen();
    int sum=0;
    System.out.println("Sum of all Digits");
    System.out.println("Enter Number");
    num=sc.nextInt();
    while(num>0){
    rem=num%10;
    sum+=rem;
    num/=10;
    }
    System.out.println("Sum = "+sum);
    break;

    case 3:
    clearscreen();
    int count=0;
    System.out.println("Number of Digits");
    System.out.println("Enter Number");
    num=sc.nextInt();
    while(num>0){
    count++;
    num/=10;
    }
    System.out.println(count+" Digits");
    break;

    case 4:
    clearscreen();
    int prod=1;
    System.out.println("Product of all Digits");
    System.out.println("Enter Number");
    num=sc.nextInt();
    while(num>0){
    rem=num%10;
    prod*=rem;
    num/=10;
    }
    System.out.println("Product = "+prod);
    break;

    case 5:
    clearscreen();
    int big=0;
    System.out.println("Biggest Digit");
    System.out.println("Enter Number");
    num=sc.nextInt();
    while(num>0){
    rem=num%10;
    if(rem>big){big=rem;}
    num/=10;
    }
    System.out.println("Biggest Number = "+big);
    break;

    case 6:
    clearscreen();
    int small=9;
    System.out.println("Smallest Digit");
    System.out.println("Enter Number");
    num=sc.nextInt();
    while(num>0){
    rem=num%10;
    if(rem<small){small=rem;}
    num/=10;
    }
    System.out.println("Smallest Number = "+small);
    break;
    default:
    System.out.println("Wrong Input");


    }
    }
    }

    ReplyDelete
  2. import java.util.Scanner;
    class MenuDriven
    {
    public static void main(String ar[])
    {
    int option,Number,Total;
    Scanner scan=new Scanner(System.in);
    System.out.println("Select any option.");
    System.out.println("1.Reverse Number");
    System.out.println("2.Sum of all Digits");
    System.out.println("3.Number of Digits");
    System.out.println("4.Product of all Digits");
    System.out.println("5.Biggest Digit");
    System.out.println("6.Smallest Digit");
    option=scan.nextInt();
    switch(option)
    {
    case 1:
    int RNumber=0;
    System.out.println("Enter the Number");
    Number=scan.nextInt();
    while(Number>0)
    {

    RNumber=RNumber*10+(Number%10);
    Number=Number/10;

    }
    System.out.println("Reverse Number="+RNumber);break;
    case 2:
    Total=0;
    System.out.println("Enter the Number");
    Number=scan.nextInt();
    while(Number>0)
    {
    Total=Total+(Number%10);
    Number=Number/10;
    }
    System.out.println("Sum is="+Total);break;
    case 3:
    int Length=0;
    System.out.println("Enter the Number");
    Number=scan.nextInt();
    while(Number>0)
    {
    Number=Number/10;
    Length++;
    }
    System.out.println("Length of a number="+Length);break;
    case 4:
    Total=1;
    System.out.println("Enter the Number");
    Number=scan.nextInt();
    while(Number>0)
    {
    Total=Total*(Number%10);
    Number=Number/10;
    }
    System.out.println("Product is="+Total);break;
    case 5:
    Total=0; int biggest=0;
    System.out.println("Enter the Number");
    Number=scan.nextInt();
    while(Number>0)
    {
    Total=Number%10;
    Number=Number/10;
    if(Total>biggest){biggest=Total;}
    }
    System.out.println("Biggest Number="+biggest);break;
    case 6:
    Total=0;int smallest=9;
    System.out.println("Enter the Number");
    Number=scan.nextInt();
    while(Number>0)
    {
    Total=Number%10;
    Number=Number/10;
    if(Total<smallest){smallest=Total;}
    }
    System.out.println("Smallest Number="+smallest);break;
    default:
    System.out.println("Please enter the correct input");


    }
    }
    }

    ReplyDelete
  3. import java.util.Scanner;

    class Test
    {

    public static void main(String ar[])
    {
    int choice,number,result,rem;
    System.out.print("Enter your choice:\n1 for reversing number.");
    System.out.print("\n2 for sum of all digit");
    System.out.print("\n3 for number of digit");
    System.out.print("\n4 for product of all digit");
    System.out.print("\n5 for largest of all digit");
    System.out.print("\n6 for smallest of all digit\n");
    Scanner w=new Scanner(System.in);
    choice=w.nextInt();
    System.out.print("Enter the number: ");
    number=w.nextInt();
    if(choice==1)
    {
    result=0;
    while(number>0)
    {
    result=result*10+(number%10);
    number=number/10;
    }
    System.out.println("The reverse of the number is: "+result);
    }
    else if(choice==2)
    {
    result=0;
    while(number!=0)
    {
    result=result+(number%10);
    number=number/10;
    }
    System.out.println("The sum of individual digits is: "+result);
    }
    else if(choice==3)
    {
    for(result=0;number>0;result++)
    {
    number=number/10;
    }
    System.out.println("The length of the number is: "+result);
    }
    else if(choice==4)
    {
    result=1;
    while(number!=0)
    {
    result=result*(number%10);
    number=number/10;
    }
    System.out.println("The product of individual numbers is: "+result);
    }
    else if(choice==5)
    {
    result=0;
    while(number!=0)
    {
    rem=number%10;
    if(rem>result)
    {
    result=rem;
    }
    number/=10;
    }
    System.out.println("The largest of digit is: "+result);
    }
    else if(choice==6)
    {
    result=10;
    while(number!=0)
    {
    rem=number%10;
    if(rem<result)
    {
    result=rem;
    }
    number/=10;
    }
    System.out.println("The smallest of digit is: "+result);
    }
    else
    System.out.println("Wrong choice!");

    }

    }

    ReplyDelete
  4. import java.util.Scanner;
    class Menu
    {
    public static void main(String Args[])
    {
    Scanner sc=new Scanner(System.in);

    System.out.println("press 1 to reverse a number");
    System.out.println("press 2 to find sum of all digit");
    System.out.println("press 3 to find numbers of digit in a number");
    System.out.println("press 4 to find product of all digits in a number");
    System.out.println("press 5 to find the biggest digit");
    System.out.println("press 6 to find the smallest digit");
    System.out.println("enter your choice");
    int c=sc.nextInt();
    int count=0;
    int num,rem;
    if(c==1)
    {
    System.out.println("enter the integer");
    num=sc.nextInt();
    int rev_num=0;
    while(num>0)
    {
    int digit=num%10;
    rev_num=rev_num*10+digit;
    num/=10;
    }
    System.out.println("reverse="+rev_num);
    }
    if(c==2)
    {
    System.out.println("enter the integer");

    num=sc.nextInt();
    int sum=0;
    while(num!=0)
    {
    sum=sum+num%10;
    num=num/10;
    }
    System.out.println("sum is"+sum);
    }
    if(c==3)
    {
    System.out.println("enter the integer");

    num=sc.nextInt();
    while(num!=0)
    {count++;
    num=num/10;
    }
    System.out.println("number of digits are "+count);
    }
    if(c==4)
    {
    int mul=1;
    System.out.println("enter the integer");
    num=sc.nextInt();
    while(num!=0)
    {
    mul=mul*(num%10);
    num=num/10;
    }
    System.out.println("product of number is "+mul);
    }
    if(c==5)
    {
    int big=0;
    System.out.println("enter the integer");
    num=sc.nextInt();
    while(num!=0)
    {
    rem=num%10;
    if(rem>big)
    {big=rem;}
    num=num/10;
    }
    System.out.println("big digit is"+big);
    }
    if(c==6)
    {
    int small=9;
    System.out.println("enter the integer");
    num=sc.nextInt();
    while(num!=0)
    {
    rem=num%10;
    if(rem=7)
    {
    System.out.println("wrong choice");
    }
    }}

    ReplyDelete
  5. 21.1
    import java.util.Scanner;
    class A
    {
    public static void main(String args[])
    {
    Scanner obj=new Scanner(System.in);
    int num;
    int reverse=0;
    int remainder;
    num=obj.nextInt();
    while(num>0)
    {
    remainder=num%10;
    reverse=reverse*10+remainder;
    num=num/10;
    }
    System.out.println("The reverse of the number is="+reverse);
    }
    }
    21.2
    import java.util.Scanner;
    class A
    {
    public static void main(String args[])
    {
    Scanner obj=new Scanner(System.in);
    int num;
    num=obj.nextInt();
    int sum=0;
    int q;
    while(num>0)
    {
    q=num%10;
    sum=sum+q;
    num/=10;
    }
    System.out.println(sum);
    }
    }
    21.5
    import java.util.Scanner;
    class A
    {
    public static void main(String args[])
    {
    Scanner obj=new Scanner(System.in);
    int num;
    num=obj.nextInt();
    int remainder;
    int large=0;
    while(num>0)
    {
    remainder=num%10;
    if(remainder>large)
    {
    large=remainder;
    }
    num=num/10;
    }
    System.out.println(large);
    }
    }
    21.6

    import java.util.Scanner;
    class A
    {
    public static void main(String args[])
    {
    Scanner obj=new Scanner(System.in);
    int num;
    num=obj.nextInt();
    int remainder;
    int large=num;
    while(num>0)
    {
    remainder=num%10;
    if(remainder<large)
    {
    large=remainder;
    }
    num=num/10;
    }
    System.out.println(large);
    }
    }

    ReplyDelete
  6. import java.util.Scanner;
    public class menudriven
    {
    /*21. Menu driven program

    Reverse number.
    Sum of all digit.
    Number of digit.
    Product of all digit.
    Big digit.
    Smallest digit. */

    public static void main(String ar[])
    {
    Scanner scan = new Scanner(System.in);
    int ch;
    int remainder, num;
    System.out.println("Enter the number :");
    num = scan.nextInt();
    System.out.println(" 1. REVERSE NUMBER");
    System.out.println("2. SUM OF ALL DIGIT");
    System.out.println("3. NUMBER OF DIGIT");
    System.out.println("4. PRODUCT OF ALL DIGIT");
    System.out.println("5. BIG DIGIT");
    System.out.println("6. SMALLEST DIGIT");
    System.out.println(" Enter your choice : ");
    ch = scan.nextInt();

    if( ch == 1)
    {
    System.out.println(" Welcome to reverse number menu");
    int reverseno=0;
    while(num>0)
    {
    remainder = num % 10;
    reverseno = reverseno*10+remainder;
    num/=10;
    }
    System.out.println("the reverse number is : "+reverseno);
    }

    else
    if(ch==2)
    {
    System.out.println(" Welcome to sum of all digits menu");
    int sum=0;
    while(num>0)
    {
    remainder = num%10;
    sum+=remainder;
    num/=10;
    }
    System.out.println("the sum of all digits is :" +sum);
    }

    else
    if(ch==3)
    {
    System.out.println(" Welcome to number of digits menu");
    int count=0;
    while(num>0)
    {
    remainder = num%10;
    count++;
    num/=10;
    }
    System.out.println(" the number of digits are : " +count);
    }

    else
    if(ch==4)
    {
    System.out.println(" Welcome to product of digits menu");
    int product=1;
    while(num>0)
    {
    remainder = num%10;
    product*=remainder;
    num/=10;
    }
    System.out.println("the product of all digits is :" +product);
    }

    else
    if(ch==5)
    {
    System.out.println(" Welcome to big digit menu");
    int big=0;
    while(num>0)
    {
    remainder = num%10;
    if(remainder>big)
    {
    big=remainder;
    }
    num/=10;
    }
    System.out.println("the biggest digit is :"+big);
    }
    else
    if(ch==6)
    {
    System.out.println(" Welcome to big digit menu");
    int small=9;
    while(num>0)
    {
    remainder = num%10;
    if(remainder<small)
    {
    small=remainder;
    }
    num/=10;
    }
    System.out.println("the smallest digit is :"+small);
    }
    }
    }

    ReplyDelete
  7. import java.util.Scanner;
    class Logical{
    public static void main(String ar[]){
    Scanner obj=new Scanner(System.in);
    int n,cha,ch;

    System.out.println("enter the operation you would like to be done on the number");
    System.out.println("press 1. for reversing the no");
    System.out.println("press 2. for sum of all the digits of the no");
    System.out.println("press 3. for finding the no. of digits in the no");
    System.out.println("press 4. for product of the digit of the no");
    System.out.println("press 5. for printing the largest digit of the no");
    System.out.println("press 6. for printing the smallest digit of the no");
    cha=obj.nextInt();
    do{
    System.out.println("enter the value of the number");
    n=obj.nextInt();
    switch(cha){
    case 1:
    int rem;
    while(n!=0)
    {
    rem=n%10;
    n=n/10;
    System.out.print(rem);
    }
    break;
    case 2:
    int rem1,sum=0;

    while(n!=0){
    rem1=n%10;
    n=n/10;
    sum=sum+rem1;
    }
    System.out.println("sum is"+sum);break;
    case 3:
    int i=0;
    while(n!=0)
    {
    n=n/10;
    i++;
    }
    System.out.println("the length of the number is"+i);break;
    case 4:
    int rem2,mul=1;
    while(n!=0){
    rem2=n%10;
    n=n/10;
    mul=mul*rem2;
    }
    System.out.println("product is"+mul);break;
    case 5:
    int big=0,rem3;
    while(n!=0){
    rem3=n%10;
    if(rem3>big)
    big=rem3;
    n=n/10;
    }
    System.out.println("the biggest digit is"+big);break;
    case 6:
    int small=9,rem4;

    while(n!=0){
    rem4=n%10;
    if(rem4<small)
    small=rem4;
    n=n/10;
    }
    System.out.println("the smallest digit is"+small);

    break;
    default:
    System.out.println("wrong choice entered");
    }
    System.out.println("do you want to try it one more time, press 10");
    ch=obj.nextInt();
    }while(ch==10);






    }
    }

    ReplyDelete
  8. import java.util.Scanner;

    class Project{
    public static void main(String ar[]){
    int a,b,num,X=0;
    System.out.println("1.Reverse number");
    System.out.println("2.Sum Of All Digits");
    System.out.println("3.Number Of Digits");
    System.out.println("4.Product Of All Digits");
    System.out.println("5.Big Digit");
    System.out.println("6.Small Digit");
    System.out.println("7.Palindrome");
    Scanner scan= new Scanner(System.in);
    System.out.println("Enter your Choice");
    a=scan.nextInt();

    if(a==1){

    System.out.println("Enter number");
    num=scan.nextInt();
    for(;num != 0; num /= 10) {
    int digit = num % 10;
    X = X * 10 + digit;
    }

    System.out.println("Reversed Number: " + X);

    }else if(a==2){
    System.out.println("Enter number");
    num=scan.nextInt();
    while(num > 0)
    {
    b = num % 10;
    X = X + b;
    num = num / 10;
    }
    System.out.println("Sum of Digits:"+X);
    }else if(a==3){
    System.out.println("Enter number");
    num=scan.nextInt();
    while(num != 0)
    {
    num = num/10;
    //num /= 10;
    ++X;
    }

    System.out.println("Number of digits: " + X);


    }else if(a==4){
    int prod=1;
    System.out.println("Enter number");
    num=scan.nextInt();
    while(num!=0)
    {
    X=num%10;
    num=num/10;
    prod=prod*X;
    }
    System.out.println(prod);


    }else if(a==5){
    System.out.println("Enter number");
    num=scan.nextInt();
    while (num > 0) {
    b = num % 10;
    if (X < b) {
    X = b;
    }
    num = num / 10;
    }

    System.out.println("\nThe Largest Digit is :" + X);



    }else if(a==6){
    int S=9;
    System.out.println("Enter number");
    num=scan.nextInt();
    while (num > 0) {
    b = num % 10;
    if (S > b) {
    S = b;
    }
    num = num / 10;
    }

    System.out.println("\nThe Largest Digit is :" + S);



    }else if(a==7){
    int temp;
    System.out.println("Enter number");
    num=scan.nextInt();
    temp=num;
    while(num>0){
    b=num%10;
    X=(X*10)+b;
    num=num/10;
    }
    if(temp==X)
    System.out.println("palindrome number ");
    else
    System.out.println("not palindrome");



    }else{
    System.out.println("GET LOST");

    }

    }


    }


    ReplyDelete
  9. import java.util.Scanner;
    class Menu{
    public static void main(String ar[]){
    int number,digit=0,rem=0,sum=0,i,c,length=0,product=1,big=0,small=9;
    Scanner scan=new Scanner(System.in);
    System.out.println("Enter the number:");
    number=scan.nextInt();
    System.out.println("1.Reverse Number");
    System.out.println("2.Sum of all Digits");
    System.out.println("3.Number of Digits");
    System.out.println("4.Product of all Digits");
    System.out.println("5.Biggest Digit");
    System.out.println("6.Smallest Digit");
    c=scan.nextInt();
    switch(c){

    case 1:
    while(number>0) {
    digit=number%10;
    rem=(rem*10)+digit;
    number=number/10;}
    System.out.println("Reverse of the digits of number:"+rem);
    break;
    case 2:

    while(number>0) {
    digit=number%10;
    sum=sum+digit;
    number=number/10;}
    System.out.println("Sum of the digits of number:"+sum);
    break;

    case 3:
    while(number>0){
    number=number/10;
    length++;}
    System.out.println("length of the digits of number:"+length);
    break;

    case 4:
    while(number>0) {
    digit=number%10;
    product=product*digit;
    number=number/10;}
    System.out.println("product of the digits of number:"+product);
    break;

    case 5:
    while(number>0) {
    digit=number%10;
    number=number/10;
    if(digit>big){
    big=digit;}}
    System.out.println("Biggest digit among number:"+big);
    break;

    case 6:
    while(number>0) {
    digit=number%10;
    number=number/10;
    if(digit<small){
    small=digit;}}
    System.out.println("Smallest digit among number:"+small);
    break;
    default:
    System.out.println("INVALID!!!");
    }
    }
    }

    ReplyDelete
  10. import java.util.Scanner;
    public class Menu {
    public static void main(String args[]){
    String condition ;
    int Menu, Option;
    double Number;
    Scanner s=new Scanner(System.in);
    System.out.println("Select the any option given below: ");
    System.out.println("1. Reverse Number ");
    System.out.println("2. Sum of all Digit ");
    System.out.println("3. Number of digit ");
    System.out.println("4. Product of all Number ");
    System.out.println("5. Biggest Digit ");
    System.out.println("6. Smallest Digit ");
    Option=s.nextInt();
    switch(Option){
    case 1:
    double RNumber=0;
    System.out.println("Enter the Number");
    Number=s.nextDouble();
    while(Number>0)
    {

    RNumber=RNumber*10+(Number%10);
    Number=Number/10;

    }
    System.out.println("Reverse Number="+RNumber);

    break;
    case 2:
    double Total=0;
    System.out.println("Enter the Number");
    Number=s.nextDouble();
    while(Number>0)
    {
    Total=Total+(Number%10);
    Number=Number/10;
    }
    System.out.println("Sum is="+Total);
    break;
    case 3:
    int Length=0;
    System.out.println("Enter the Number");
    Number=s.nextDouble();
    while(Number>0)
    {
    Number=Number/10;
    Length++;
    }
    System.out.println("Length of a number="+Length);
    break;
    case 4:
    double iTotal=1;
    System.out.println("Enter the Number");
    Number=s.nextDouble();
    while(Number>0)
    {
    iTotal=iTotal*(Number%10);
    Number=Number/10;
    }
    System.out.println("Product is="+iTotal);
    break;
    case 5:
    double pTotal=0; double biggest=0;
    System.out.println("Enter the Number");
    Number=s.nextDouble();
    while(Number>0)
    {
    pTotal=Number%10;
    Number=Number/10;
    if(pTotal>biggest){biggest=pTotal;}
    }
    System.out.println("Biggest Number="+biggest);
    break;
    case 6:
    double jTotal=0;double smallest=9;
    System.out.println("Enter the Number");
    Number=s.nextDouble();
    while(Number>0)
    {
    jTotal=Number%10;
    Number=Number/10;
    if(jTotal<smallest){smallest=jTotal;}
    }
    System.out.println("Smallest Number="+smallest);
    break;
    default:
    System.out.println("Please enter the correct input");
    System.out.println("Do you Wnat to continue type 'yes'or no ");
    condition=s.next();

    }
    while (condition.equals("yes")||condtion.equals("y")||condtion.equals("YES")||condtion.equals("Yes"));


    }
    }

    ReplyDelete