source file name: FlowerDemo.java class FlowerDemo { public void sateFlower() { System.out.println("Rose is beautiful flower"); } public void sateFlower(String s) { System.out.println(s+" is beautiful flower"); } public void sateFlower(String s, int n) { for(int i=1;i<=n;i++) { System.out.print…
Read more4) Write a Java program that to convert any given year into its Roman equivalents using Method overloading.
source file name: romandemo.java import java.io.*; class Roman { final char[] ch={'M','D','C','L','X','V','I'}; void roman(int cnt,char ch) { for(int n=1;n<=cnt;n++) System.out.print(ch+" "); } } class romandemo extends Roman { void roman(int n) { …
Read more3) Convert Decimal number to Binary , Octal and Hexadecimal with Method Overloading.
source code name: ConversionDemo.java class ConversionDemo { void convert(int n, String s) // method over loaded with integer and String ( type 1) { int b=0,i; int rem[]=new int[10]; i=0; if(s.equals("binary")) { b=2; System.out.print("\nBinary Conversion: "); } if(s.equals("octal")) { b…
Read more2) Write a Java program that finds area of square and rectangle using Method Overloading.
class Area { public void A(int l) { System .out.println("area of square is="+(l*l)); } public void A(int l,int b) { System.out.println("area of rectangle is="+(l*b)); } } class action extends Area { Area a; public action() { a=new Area(); a.A(4); a.A(4,5); } …
Read moreclass Interest { int p,r; public void findInterest(int p,int r) { System.out.println("The interest for one year is:"+(p*r/100)); } public void findInterest(int p,int r,int y) { System.out.println("The interest for"+y+"year is:"+(p*r*y/100)); } } class Actions e…
Read more