Write a program that inputs 4 numbers and calculates the sum, average and product of all the numbers.

public static void main(String[] args) { Scanner x=new Scanner(System.in); int a,b,c,d,sum,avg,pro; System.out.println(“Enter number”); a=x.nextInt(); System.out.println(“Enter number”); b=x.nextInt(); System.out.println(“Enter number”); c=x.nextInt(); System.out.println(“Enter number”); d=x.nextInt(); sum=a+b+c+d; avg=(a+b+c+d)/4; pro=a*b*c*d; System.out.println(“Sum of number is …

Read More

.Write a program that inputs amount in rupees find and print it how many 100,50,20,10,5,2,1 rupee notes could be made.

public static void main(String[] args) { Scanner cin=new Scanner(System.in); int rs,hundred,fifty,twenty,ten,five,two,one; System.out.println(“Enter rupees=”); rs=cin.nextInt(); hundred=rs/100; rs=rs%100; fifty=rs/50; rs=rs%50; twenty=rs/20; rs=rs%20; ten=rs/10; rs=rs%10; five=rs/5; rs=rs%5; two=rs/2; one=rs%2; System.out.println(“hundred ruppes are”+hundred); System.out.println(“Fifty …

Read More

Write a program that inputs days and displays possible years, month and weeks of that input.

  public static void main(String[] args) { Scanner n=new Scanner(System.in); int d,m,y,w; System.out.println(“Enter age=”); d= n.nextInt(); y=d/365; d=d%365; m=d/30; d=d%30; w=d/7; d=d%7; System.out.println(“year are=”+y); System.out.println(“months are=”+m); System.out.println(“weeks are=”+w); System.out.println(“days are=”+d); …

Read More