Computer Science, asked by emily637, 2 months ago

1) Write a program in Java to find out
the volume of a cone where radius is
and height is h. II) Write a java program
to determine whether an input number
is an odd or even number.​

Answers

Answered by devarchanc
0

Java Program

Explanation:

i. To find out  the volume of a cone where radius is  r and height is h

import java.util.Scanner;

public class volume

{      

  public static void main(String args[])  

   {      

            Scanner s= new Scanner(System.in);

              double r, h, vol;

        System.out.println("Enter the radius of cone:");

         r=s.nextDouble();

               System.out.println("Enter the height of cone:");

              h=s.nextDouble();      

              vol=(22*r*r*h)/(3*7);  

              System.out.println("Volume of Cone is:" +vol);        

  }

}

ii. To determine whether an input number  is an odd or even number.​

import java.util.Scanner;

public class OddEven  

{

   public static void main(String[] args)  

   {

       int num;

       Scanner s = new Scanner(System.in);

       System.out.print("Enter the number:");

       num = s.nextInt();

       if(num % 2 == 0)      

           System.out.println("The given number is Even ");

       else

           System.out.println("The given number is Odd ");  

   }

}

Similar questions