Skip to main content

Posts

Showing posts with the label Java

ads1

JAVA PROGRAM || Write a JAVA program to enter P, T, R and calculate Simple Interest.

                                                 JAVA PROGRAM Write a Java program to enter P, T, R and calculate Simple Interest.   (Hint) Simple Intereset = P*R*T/100   Static  class SimpleInterest {     public static void main(String args[])     {         double p=25000.50,r=8.5,t=5;         double sp = p * r * t/100;         System.out.println("The simple interset is :- "+sp);     } }   Output :-     Dynamic :-  import java.util.*; class SimpleInterest {     public static void main(String args[])     {           Scanner in = new Scanner(System.in);      System.out.println("Enter the Principle amount :-");     double principle = in.nextDouble();     System.out.println("Enter the Rate of interest :-");     double rate = in.nextDouble();     System.out.println("Enter the Time period  :-");     double time = in.nextDouble();     double sp = principle * rate * time/100;     System.out.println("The simple interset is :- "+sp);     } } Out

JAVA PROGRAM || Write a JAVA program to enter marks of five subjects and calculate total, average and percentage.

                                                                                            JAVA PROGRAM   Write a Java program to enter marks of five subjects and calculate total, average and percentage.   (Hint)  Total = s1+s2+s3+s4+s5 Average = total/5 percentage = (total/500)*100 Static :-  class TAP {     public static void main(String args[])     {         double english=50.0,Maths=65.5,SocialScience=72.5,Science=49.0,Computer=48.5,total,average,percentage;         total=english+Maths+SocialScience + Science + Computer;         average = total/5;         percentage = (total/500)*100;         System.out.println("The total marks is :-"+total);         System.out.println("The average  is :-"+average);         System.out.println("The percentage is :-"+percentage);                  } }   Output :-      Dynamic :-  import java.util.*; class TAP {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.ou

JAVA PROGRAM || Write a JAVA program to convert days into years, weeks and days.

                                                                                       Write a Java  program to convert days into years, weeks and days.   (hint)  year = days/365 week = (day % 365)/7) days = days-(year*365)+(weeks*7)) Static :- class YWD {     public static void main(String args[])     {         int day=500;         int year,week,days;         year = (day/365);         week = (day % 365)/7;         days = day-((year*365)+(week*7));         System.out.println("The number of year :- "+year);         System.out.println("The number of week :- "+week);         System.out.println("The number of days :- "+days);     }    } Output :-    Dynamic :- import java.util.*; class YWD {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the number of Days :- ");         int day = in.nextInt();         int year,week,days;         year = (day/365);         week = (day % 3

JAVA Program || Write a Java program to enter temperature in Fahrenheit and convert to Celsius.

                                                 Write a Java program to enter temperature in Fahrenheit and convert to Celsius   (Hint) C= (f-32)*9/5 Static :-  class Celsius {     public static void main(String args[])     {         Double fah = 205.0;         Double cel;         cel = (fah - 32)*5/9;         System.out.println("The temperature in Celsius is :- "+cel);     } } Output :-    Dynamic  import java.util.*; class Celsius {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the Temperature in Faherenheit :-");         double fah = in.nextDouble();         double cel = (fah-32)*5/9;         System.out.println("The temperature in Celsius is :- "+cel);     } } Output :-         

Java Program || Write a Java program to enter temperature in Celsius and convert it into Fahrenheit.

                                                                                            JAVA Program       Write a Java program to enter temperature in Celsius and convert it into Fahrenheit. (Hint) fahrenheit = (celsius * 9 / 5) + 32.   Static :-  class fahreheit {     public static void main(String args[])     {         double celsius = 100 ,fahreheit;         fahreheit = (celsius * 9 / 5) + 32;         System.out.println("The fahreheit is :- "+fahreheit);       } } Output :-       Dynamic :- import java.util.*; class fahreheit {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the temperature in celsius");         Double cel = in.nextDouble();         double fah = (cel * 9/5)+32;         System.out.println("The Temperature in Fahreheit is :- "+fah);     } } Output :-       

Java Program || Write a Java program to enter length in centimeter and convert it into meter and kilometer.

                                                                                             Java Program  Write a Java program to enter length in centimeter and convert it into meter and kilometer.   Solution :-  meter = cm / 100.0; km    = cm / 100000.0;   Static :-  class convert {     public static void main(String args[])     {         double cm=1000,meter,km;         meter = cm/100.0;         km = cm/100000.0;         System.out.println("The meter :-"+meter);         System.out.println("The Kilometer is :-"+km);              }     } Output :-    Dynamic :-  import java.util.*; class convert {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the cm :- ");         int cm = in.nextInt();         double meter = cm/1000.0;         double km = cm/100000.0;         System.out.println("The meter :-"+meter);         System.out.println("The Kilometer is :-"+km);

Java Program || Write a Java program to enter radius of a circle and find its diameter, circumference and area.||

                                 JAVA PROGRAM   Write a Java program to enter radius of a circle and find its diameter, circumference and area. Solution :-  (Hint)  diameter = 2 * radius, circumference = 2 * 3.14 * radius area = 3.14 * radius * radius   Static :-   class circle {     public static void main(String args[])     {         int radius = 10;         double pi = 3.14;            double diameter,circumference,area;         diameter = 2 *radius;         circumference = 2 * pi * radius;         area = pi * radius * radius;         System.out.println("The diameter of the circle :-"+diameter);         System.out.println("The circumference of the circle :-"+circumference);         System.out.println("The area of the circle"+area);         } }   Output :-      Dynamic :-  import java.util.*; class circle {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the radius :- &q

Java Program || Write a Java program to enter length and breadth of a rectangle and find its area.||BCA Sem- 4

     Java Program Static Program :-  class arectangle {     public static void main(String args[])     {         int length = 10,width=20,area;         area = length * width;         System.out.println("The area of rectangle is :-"+area);     } }   Output :-  '   Dynamic :- import java.util.*; class arectangle {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the length :- ");         int length = in.nextInt();         System.out.println("Enter the Width :- ");         int width = in.nextInt();         int area = length * width;         System.out.println("The area of Rectangle is :- "+area);        } }   Output :-         

Java Program || Write a Java program to enter length and breadth of a rectangle and find its perimeter.

          JAVA Program                                Static   Write a Java program to enter length and breadth of a rectangle and find its perimeter. class prectangle { public static void main(String args[]) { int length=10,Width=5; int perimeter = 2*(length + Width); System.out.println("The perimeter of rectangle is :- "+perimeter); } } Output :-  Dynamic  import java.util.*; class prectangle { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter the Length"); int len = in.nextInt(); System.out.println("Enter the Width"); int Width = in.nextInt(); int perimeter = 2*(len + Width); System.out.println("The perimeter of a rectangle is :-" +perimeter); } } Output :- 

Java Program || Write a Java program to enter two numbers and perform all arithmetic operations.

JAVA Program  Static Write a Java program to enter two numbers and perform all arithmetic operations.  Sol  :-  class arithmetic  { public static void main(String args[]) { int a=10,b=20; int add = a+b; int sub = a-b; int mul = a*b; int div = a/b; int mod = a%b; System.out.println("The sum of two number is :-"+add); System.out.println("The sub of two number is :-"+sub); System.out.println("The mul of two number is :-"+mul); System.out.println("The div of two number is :-"+div); System.out.println("The mod of two number is :-"+mod); } } Output :-  Dynamic import java.util.*; class arithmetic  { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter the first number :- "); int a = in.nextInt(); System.out.println("Enter the Second number :- "); int b = in.nextInt(); int add = a+b; int sub = a-b; int mul =

Java Programming||Write a Java Program to enter two numbers and find their sum.

                                                           JAVA Program                            Static Program  :- 1. Write a Java Program to enter two numbers and find their sum. class sum { public static void main(String args[]) { int a=10; int b=20; int c = a+b; System.out.println("The Sum of two number is :- "+c); } } Output :-  Dynamic  :-  import java.util.*; class sum { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter the first number :- "); int a=in.nextInt(); System.out.println("Enter the Second number :- "); int b=in.nextInt(); int c = a+b; System.out.println("The sum of two number is :- "+c); } } Output :- 

Java Programming || Write a Java program to Print Hello World. || BCA Sem-4

  JAVA Programming   1. Write a Java program to Print Hello World.  class helloworld { public static void main(String args[]) { System.out.println("Hello World"); } } Output :-  Explain    To create a Java Program ,  First , We have to create a Class, and assign the Name for your java program. Second , We have to write "public static void main(String args[])"   Public :- Public is an Access modifier, If we use public access specifier. It will be easy access the method . If we make the main() method public makes it globally available. Static :- Static is a keyword , Which is when associated with a method , it is a class related method. If we make main method Static ,JVM can invoke it without instantiating the class. Void :- Void is a keyword, basically void means Nothing . It  used to specify that a method doesn’t return anything. Main :- It is a java main method.  It’s not a keyword.  It is basically a identifier that JVM look for  as the starting point

ads2