6 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[])
    {
    while(1==1){

    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");
    }

    System.out.println("Do you want to continue? (Y/N)");
    continuee=sc.next();

    if(continuee.equals("no")||continuee.equals("n")||continuee.equals("NO")||continuee.equals("N")){
    System.exit(0);
    }
    else if(continuee.equals("yes")||continuee.equals("y")||continuee.equals("YES")||continuee.equals("Y")){}
    else{System.out.println("Program continued due to Wrong Input.");}
    clearscreen();
    }
    }
    }

    ReplyDelete
  2. import java.util.Scanner;
    class MenuDrivenDo
    {
    public static void main(String ar[])
    {
    int option,Number,Total;String condition="";
    do{
    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");
    }
    System.out.println("Do you want to continue");
    condition=scan.next();
    }while(condition.equals("y")||condition.equals("yes")||condition.equals("YES")||condition.equals("Yes"));

    };
    }

    ReplyDelete
  3. import java.util.Scanner;

    class Test
    {

    public static void main(String ar[])
    {
    int choice,number,result,rem;
    char permission;
    do
    {

    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();
    String answer;
    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!");

    System.out.print("\nDo you want to continue?(Y for yes/N for no)");
    answer=w.next();
    permission=answer.charAt(0);

    }while(permission=='y'||permission=='Y');

    }
    }

    ReplyDelete
  4. import java.util.Scanner;
    class Menu
    {
    public static void main(String Args[])
    {String condition="";
    Scanner sc=new Scanner(System.in);
    do{
    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");
    }
    System.out.println("do you want to continue");
    System.out.println("press Y to continue");
    System.out.println("press N to exit");
    condition=sc.next();
    }
    while(condition.equals("y")||condition.equals("Y"));
    }}

    ReplyDelete
  5. 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,ch1;
    int remainder, num;
    System.out.println("Enter the number :");
    num = scan.nextInt();
    do
    {
    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);
    }

    System.out.println("do you want to continue ?");
    System.out.println("press Y or y to continue");
    System.out.println("press N or n to continue");
    ch1 = scan.nextInt();

    }while(ch1=='y'||ch1=='Y')
    }
    }

    ReplyDelete
  6. 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