Saturday, July 3, 2021

Menu Driven Program On Number

 
Take a number (<1000) , if it is single digit then display the number in word otherwise display the number in the following format : 12 as 0012, 123 as 0123 and so on

Sample Input Output

Enter a Number: 8
Output: Eight
Enter a Number: 18
Output: 0018

class MenuDriven
{
  
   void show(int a, int b) 
        { 
          if(a>b)
          sub(a,b);
          else
          sum(a,b);
        }
        private void sum(int a, int b)
        {
            int c=a+b;
            System.out.print("\nSUM = "+c);
        }
        private void sub(int a, int b)
        {
            int c=a-b;
            System.out.print("\nSUB = "+c);
        }
public static void main(String args[])
{
MenuDriven ob = new MenuDriven();
ob.show(12,14);
}
 }

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner