Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Variable and Constant in Java:-





Variable or Data Member:-  It is a special identifier whose value can be changed at compile-time or runtime.

Variable declaration Syntax:-

 access modifier + non access modifier +  datatype + identifier

 public                     static         int               x

int x =10 ;    //default instance int x=10 dynamic memory allocation using object

static int y=20 //  default static int y=20 one-time memory allocated at compile time


Types of variable:-

1 Instance or Dynamic:-

It will be declared without any static modifier and it will be allocated memory at the time of execution by the object.

a variable which will be declared underclass or under instance method without using static modifier will be instance variable


instance variable will never declare under static method but it can be used.

this type of variable is also called dynamic data members in OOP'S Programming. means non-static, instance, dynamic all are the same.


Example of nonstatic variable:-


class Dynamic
{
   int a,b,c;
   
    public static void main(String args[])
    {
      Dynamic obj= new Dynamic(); 
      obj.a=100;
      obj.b=200;
      obj.c=obj.a+obj.b;
      System.out.println(obj.c);

    }

}

class A
{
    int x=10; //global instance variable
    void fun()
    {
       int y=20; //local instance variable
    }

}

A obj = new A();  //object


Complete Explanation by Program:-

class Add
{
   int a=100,b=200,c;
   public static void main(String args[])
   {
      Add obj = new Add();
      obj.c=obj.a+obj.b;
      System.out.println(obj.c);
      Add obj1 = new Add();
      obj1.a=10;
      obj1.b=20;
      obj1.c=obj1.a+obj1.b;
      System.out.println(obj1.c);
   } 


}



2 Static:-

This type of variable will allocate memory after compile-time, static has constant memory but not the constant value, a value can be changed in the same memory multiple times.

static datatype identifier=value

static int x=100;
x=10;
x=12;


we can define static variable underclass using static keyword and static method without using the static keyword. if we define a static variable under the static method then no need to declare a static keyword.


class A
{
    static int a=100;
    void fun()
    {
        int b=20;
    }

   public static void main()
   {
      int c=30;
   }

}

Program of Static With Complete explanation?

class Add
{
   static int a=100,b=200,c;
   public static void main(String args[])
   {
       c=a+b;
      System.out.println(c);
      a=10;
      b=20;
      c=a+b;
      System.out.println(c);
   } 


}


......................................................................................................................................... 

Program explanation in Java:-

class Dynamic
{
    int a,b,c;
   
    public static void main(String args[])
    {
      Dynamic obj=new Dynamic();
      obj.a=100;
      obj.b=200;
      obj.a=20;
      Dynamic obj1=new Dynamic();
      obj1.a=2000;
      obj1.b=3000;
      obj=obj1;
      obj.c=obj.a+obj.b;
   
      System.out.println(obj.c);

    }

}
Constant:-
....................................................................................................................................................

If we can not change the value of the identifier at compile-time or run-time then it is called constant.

java provides the final keyword to a constant declaration.

final static datatype variablename=value;

constant memory always will be static by default.


class ConstDemo
{
   final static int A=100;
     
   public static void main(String args[])
   {
       A=20;
       System.out.println(A);

   }


}





Assignment:-

1)WAP to calculate electricity bill where unit price and total consumption will be assigned by the users?


2)  WAP to calculate salary where basic, ta, da, comm, pf,hra,noofleave will be assigned by the users?

3)  WAP to calculate the multiplication of complex numbers?

The solution to this program:-
class Complex
{

    public static void main(String args[])
    {
       int a,b,c,d,r,i;
       a=2;
       b=3;
       c=4;
       d=5;
       r = a*c-b*d;
       i = a*d+b*c;
       System.out.println(r + "+" + i + "i");
  
    }


}


Program to perform the addition of complex numbers?

class Complex
{

    public static void main(String args[])
    {
       int a,b,c,d,r,i;
       a=2;
       b=3;
       c=4;
       d=5;
       r = a+c;
       i = b+d;
       System.out.println(a + "+" + b + "i");
       System.out.println(c + "+" + d + "i");
       System.out.println(r + "+" + i + "i");
  
    }


}

4)  WAP to find the maximum number in any three-digit number?
int a= 457 ;  //7


5)  WAP to find middle numbers using three-digit numbers?


6)  WAP to calculate the area of a circle where pi will be constant and radius will be variable?


7)  WAP to calculate simple interest using instance type variable?


8)  WAP to convert temperature from Celsius to Fahrenheit using static data members globally?


c/5 = f-32/9














71 Comments

If you have any doubt in programming or join online classes then you can contact us by comment .

  1. class Electro
    {
    public static void main(String args[])
    {
    int up=10,c=300;
    int eb=up*c;
    System.out.println(eb);
    }
    }

    ReplyDelete
  2. class Maxt
    {
    public static void main(String args[])
    {
    int a=247;
    int d1,d2,d3,max;
    d3=a%10;
    a=a/10;
    d2=a%10;
    a=a/10;
    d1=a;
    max=d1;
    if(max<d2)
    {
    max=d2;
    }
    if(max<d3)
    {
    max=d3;
    }
    System.out.println("Highest Digit is: "+max);
    }
    }

    ReplyDelete
  3. class Middle
    {
    public static void main(String args[])
    {
    int a=247;
    int m;
    a=a/10;
    m=a%10;
    System.out.println("Middle Digit is: "+m);
    }
    }

    ReplyDelete
  4. class Area
    {
    public static void main(String args[])
    {
    double r=14;
    double area= Math.PI*r*r;
    System.out.println("Area of circle with radius "+r+" is: "+area);
    }
    }

    ReplyDelete
  5. import java.util.Scanner;
    class complexnum
    {
    public static void main(String[]arg)
    {
    int a,b,c,d;
    Scanner sc=new Scanner(System.in);

    System.out.println("enter the value of a");
    a=sc.nextInt();
    System.out.println("enter the value of b");
    b=sc.nextInt();
    System.out.println("enter the value of c");
    c=sc.nextInt();
    System.out.println("enter the value of d");
    d=sc.nextInt();
    int r=a*c-b*d;
    int i=a*d+b*c;
    System.out.println(r+"+"+i+"i");
    }
    }

    ReplyDelete
  6. Q:- Example of non-static variable :-
    Solution:-
    class Dynamic
    {
    int a,b,c;

    public static void main(String args[])
    {
    Dynamic obj= new Dynamic();
    obj.a=929;
    obj.b=584;
    obj.c=obj.a+obj.b;
    System.out.println(obj.c);
    }
    }

    ReplyDelete
  7. Q:- Complete Explanation of non-static Vairiable by Program:-
    Solution:-
    class Add
    {
    int a=929,b=854,c;
    public static void main(String args[])
    {
    Add obj = new Add();
    obj.c=obj.a+obj.b;
    System.out.println(obj.c);
    Add obj1 = new Add();
    obj1.a=25;
    obj1.b=75;
    obj1.c=obj1.a+obj1.b;
    System.out.println(obj1.c);
    }
    }

    ReplyDelete
  8. Q:- WAP to calculate the multiplication of complex numbers ??
    Solution :-
    class Complex
    {

    public static void main(String args[])
    {
    int a,b,c,d,r,i;
    a=2;
    b=3;
    c=4;
    d=5;
    r = a*c-b*d;
    i = a*d+b*c;
    System.out.println(r + "+" + i + "i");
    }
    }

    ReplyDelete
  9. Q:- Program to perform the addition of complex numbers ??
    Solution:-
    class Complex
    {

    public static void main(String args[])
    {
    int a,b,c,d,r,i;
    a=2;
    b=3;
    c=4;
    d=5;
    r = a+c;
    i = b+d;
    System.out.println(a + "+" + b + "i");
    System.out.println(c + "+" + d + "i");
    System.out.println(r + "+" + i + "i");
    }
    }

    ReplyDelete
  10. class Ebill
    {
    public static void main(String args[])
    {
    int tunit=100, punit=4, ebill;
    ebill=tunit*punit;
    System.out.println(ebill);
    }
    }


    ReplyDelete
  11. // maximum number in any three-digit number
    class MaxNumber
    {
    public static void main(String args[])
    {
    int num=156;
    if((1>5) && (1>6))
    {
    System.out.println(" 1 is maximum number ");
    }
    else if(5>6 && 5>1)
    {
    System.out.println(" 5 is maximum number ");
    }
    else
    {
    System.out.println(" 6 is maximum number ");
    }
    }
    }

    ReplyDelete
  12. //Multiplication of complex numbers

    class ComplexMul
    {
    public static void main(String args[])
    {
    int a=3, b=4, c=3 ,d=4, e, f;
    e = a*b;
    f= c*d;
    System.out.println(e +"+" +f + "i^2");
    }
    }

    ReplyDelete
  13. //Maximum number in any three-digit number

    class MaxNumber
    {
    public static void main(String args[])
    {
    int num=156;
    if((1>5) && (1>6))
    {
    System.out.println(" 1 is maximum number ");
    }
    else if(5>6 && 5>1)
    {
    System.out.println(" 5 is maximum number ");
    }
    else
    {
    System.out.println(" 6 is maximum number ");
    }
    }
    }

    ReplyDelete
  14. // Middle numbers using three-digit number.


    class MiddleNumber
    {
    public static void main(String args[])
    {
    int number=369;
    int middlenumber;
    number = number/10;
    middlenumber = number%10;
    System.out.println("Middle Number = "+middlenumber);
    }
    }

    ReplyDelete
  15. //Calculate the area of a circle where pi will be constant and radius will be variable.
    class AreaCircle
    {
    static final float pi=3.14F;
    public static void main(String args[])
    {
    int r =20;
    float area;
    area=pi*r*r;
    System.out.println("Area of circle =" +area);
    }
    }

    ReplyDelete
  16. // Calculate simple interest using instance type variable?

    class Sinterest
    {
    int p,t;
    float r;
    float s;
    public static void main(String args[])
    {
    Sinterest obj= new Sinterest();
    obj.p=5000;
    obj.r=0.07F;
    obj.t=5;
    obj.s = obj.p*obj.r*obj.t;
    System.out.println(obj.s);
    }
    }


    ReplyDelete
  17. class Ebill
    {
    public static void main(String[]args)
    {
    int unitrate=10, totalunit=250, bill;
    bill= totalunit*unitrate;
    System.out.println("bill=" + bill);
    }
    }

    ReplyDelete
  18. class Complexadd
    {
    public static void main(String[]args)
    {
    int a=5,b=6,c=8,d=3,r,i;
    r=a+c;
    i=b+d;
    System.out.println(a + "+" + c + "i");
    System.out.println(b + "+" + d + "i");
    System.out.println(r + "+" + i + "i");
    }
    }

    ReplyDelete
  19. class Complexadd
    {
    public static void main(String[]args)
    {
    int a=5,b=6,c=8,d=3,r,i;
    r=a+c;
    i=b+d;
    System.out.println(r);
    System.out.println(i + "i");

    }
    }

    ReplyDelete
  20. class Complexadd
    {
    public static void main(String[]args)
    {
    int a=5,b=6,c=8,d=3,r,i;
    r=a+c;
    i=b+d;
    System.out.println(a + "+" + b + "i");
    System.out.println(c + "+" + d + "i");
    System.out.println(r + "+" + i + "i");
    }
    }

    ReplyDelete
  21. class Complexadd
    {
    public static void main(String[]args)
    {
    int a=5,b=6,c=8,d=3,r,i;
    r=a+c;
    i=b+d;

    System.out.println(r + "+" + i + "i");
    }
    }

    ReplyDelete
  22. class Obi
    {
    int a=7195, b=3595, c;
    public static void main(String[]args)
    {
    Obi obj= new Obi();
    obj.c= obj.a + obj.b;
    System.out.println(obj.c);
    }
    }

    ReplyDelete
  23. class Circle
    {
    final static double pi=3.14
    public static void main(String[]args)
    {
    double r=9, a;

    a= pi*r*r;
    System.out.println("A=" +a);
    }
    }

    ReplyDelete
  24. class Simp
    {
    int p,r,t,s;
    public static void main(String args[])

    {
    Simp obj=new Simp();
    obj.p=50000;
    obj.t=2;
    obj.r=7;
    obj.s=((obj.p*obj.t*obj.r)/100);
    System.out.println(obj.s);
    }
    }

    ReplyDelete
  25. class Mn
    {
    public static void main(String arg[])
    {
    int a=457;
    int b=a/10;
    int m=b%10;
    System.out.println(m);
    }
    }

    ReplyDelete
  26. class Area
    {
    public static void main(String arg[])
    {
    final int p=5;
    int r=2;
    int a=p*r*r;
    System.out.println(a);
    }
    }

    ReplyDelete
  27. class Sinterset
    {
    int p,t;
    float r;

    float s;
    public static void main(String arg[])
    {
    Sinterset obj=new Sinterset();
    obj.p=2000;
    obj.r=2;
    obj.t=2;
    obj.s=(obj.p*obj.r*obj.t)/100;
    System.out.println(obj.s);

    }}

    ReplyDelete
  28. class Temp
    {
    static float tc=50;
    static float f=tc*9/5+32;
    public static void main(String arg[])
    {

    System.out.println(Temp.f+"F");
    }
    }

    ReplyDelete
  29. class Complex
    {
    public static void main(String arg[])
    {
    int a,b,c,d,r,i;
    a=4;
    b=6;
    c=2;
    d=4;
    r=a*c-b*d;
    i=a*d+b*c;
    System.out.println(r+ "+" +i +"i");
    }
    }

    ReplyDelete
  30. class Max
    {
    public static void main(String arg[])
    {
    int a=257;
    int a1,a2,a3,max;
    a3=a%10;
    a=a/10;
    a2=a%10;
    a=a/10;
    a1=a;
    max=a1;
    if(max<a3)
    {
    max=a3;
    }
    if(max<a2)
    {
    max=a2;
    }
    else
    {
    System.out.println("maximum no. is"+max);
    }
    }
    }

    ReplyDelete
  31. class variable
    {
    public static void main(String args[])
    {
    int x=457;
    int y;
    y=x/10;
    int n=y%10;
    System.out.println(n);
    }
    }

    ReplyDelete
  32. class Acr
    {
    public static void main(String args[])
    {
    int r=45,pi=46;
    int a=pi*r*r;
    System.out.println(a);

    }

    ReplyDelete
  33. class A
    {
    int p,t;
    int r;
    int s;
    public static void main(String args[])
    {
    A a=new A();
    a.p=2000;
    a.r=2;
    a.t=3;
    a.s=a.p*a.r*a.t/100;
    System.out.println(a.s);
    }
    }

    ReplyDelete
  34. class cles
    {
    static void main()
    {
    float fah,cel;
    cel=13;
    fah=((cel+9)/5+32);
    System.out.println(fah);
    }
    public static void main(String args[])
    {
    cles a=new cles();
    a.main();
    }
    }

    ReplyDelete
  35. class max
    {
    public static void main(String args[])
    {
    int a=4,b=5,c=7;

    if(a>=b)
    {
    if(a>=c)
    {
    System.out.println("maximum number="+a);
    }
    else
    {
    System.out.println("maximum number="+c);

    }
    }
    else
    {
    if(b>=c)
    {
    System.out.println("maximum number="+b);

    }
    else
    {
    System.out.println("maximum number="+c);
    }
    }
    System.out.println();
    }
    }

    ReplyDelete
  36. class cles
    {

    static float cel=15;

    static float fah=((cel+9)/5+32);

    public static void main(String args[])
    {
    System.out.println(fah);

    }
    }

    ReplyDelete
  37. class Complex
    {
    public static void main(Strings args[])
    {
    int a=2,b=3;//a+ib is complex number
    int c=3,d=2;//c+id is complex number
    int x,y;
    x=(a*c)+((b*d)*-1);
    y= a*d+b*c;
    System.out.println("Result of " +a +"i"+b + "and " + c+ "i"+d+ "is ");
    System.out.println(x+"i"+z);
    }

    ReplyDelete
  38. class Complex
    {
    int p, r, t;
    public static void main(Strings args[])
    {
    float si;
    Complex c= new Complex();
    c.p = 10000,
    c.r=10;
    c.t=2;

    si =(c.p*c.r*c.t)*.01;
    System.out.print(si)
    }

    ReplyDelete

  39. WAP to find the maximum number in any three-digit number?
    int a= 457 ;

    class Bigger
    {

    public static void main(String args[])
    {

    int num,a,b,c;

    a=num%10;
    num=num/10;
    b=num%10;
    num=num/10;
    c=num%10;
    if (a>b)
    {
    if (a>c)
    {
    System.out.println(a)
    }
    else
    {
    System.out.println(c)
    }
    }
    else
    {
    if(b>c)
    {
    System.out.println(b)
    }
    else
    {
    System.out.println(c)
    }
    }
    }

    ReplyDelete
  40. #NAYANSI PURWAR

    Q.)WAP to calculate electricity bill where unit price and total consumption will be assigned by the users?

    SOL-
    import java.util.Scanner;
    class ElectricConstant
    {
    public static void main(String[] args)
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("enter unit price");
    final int unit_price;
    unit_price=sc.nextInt();
    System.out.println("enter total consumption:");
    float total_consumption=sc.nextFloat();

    float bill=unit_price*total_consumption;
    System.out.println("total bill:"+bill);

    }
    }

    ReplyDelete
  41. package Basics;

    public class greaterNo {

    public static void main(String []args)

    {
    int number=837,a,b,c,d;

    a=number%10;
    b=(int)number/10;
    c=b%10;
    d=(int)b/10;
    d=d%10;

    //System.out.println("Value is "+d);
    //System.out.println("Value is "+c);
    //System.out.println("Value is "+a);

    if(d>c && d>a)

    {
    System.out.println(d);

    }
    else if(c>a && c>d)
    {

    System.out.println(c);
    }
    else
    {
    System.out.println(a);

    }

    }

    }

    ReplyDelete
  42. package Basics;

    public class areaOfCircle {

    final static float Pi=3.14F;

    public static void main(String[] args) {

    int r=5;
    float Area;

    Area= areaOfCircle.Pi*r*r;

    System.out.println("Area of circle is "+Area);



    }

    }

    ReplyDelete
  43. #NAYANSI PURWAR

    Q)WAP to find the maximum number in any three-digit number?

    sol-class Max
    {
    public static void main(String args[])
    {

    int a,b,c,num=356;
    a=num%10;// 6
    num=num/10; //35
    b=num%10;//5
    num=num/10; //3
    c=num;
    if(a>b && a>c)
    {
    System.out.println(+a);
    }
    else if (b>c)
    {
    System.out.println(+b);
    }
    else
    {
    System.out.println(+c);
    }

    }
    }

    ReplyDelete
  44. #NAYANSI PURWAR

    Q)WAP to find middle numbers using three-digit numbers?

    sol-
    class Middle
    {
    public static void main(String args[])
    {

    int a,b,c,num=389;
    a=num%10;// 6
    num=num/10; //35
    b=num%10;//5
    num=num/10; //3
    System.out.println(b);

    }
    }

    ReplyDelete
  45. Q.) WAP to calculate the area of a circle where pi will be constant and radius will be variable?

    sol-

    import java.util.Scanner;
    class SimpleFinal

    {
    public static void main(String[] args)
    {
    Scanner sc=new Scanner(System.in);
    final float pi=3.14f;
    System.out.println("Enter radius:");
    float radius =sc.nextFloat();
    float area=pi*radius*radius;
    System.out.println("Area of circle:"+area);






    }
    }

    ReplyDelete
  46. Q) WAP to calculate simple interest using instance type variable?


    class SimpleFinal
    {
    int p=1000,t=3;
    float r=3.4f;

    public static void main(String[] args)
    {
    SimpleJava sc= new SimpleJava();
    Float SI=(sc.p*sc.r*sc.t)/100;
    System.out.println("Simple Interest:"+SI);







    }
    }

    ReplyDelete
  47. //WAP to convert temperature from Celsius to Fahrenheit using static data members globally?


    class Celcius
    {
    static double Fahrenheit,Celcius=40;
    public static void main(String[] args)
    {
    Fahrenheit=(Celcius*1.8)+32;
    System.out.println("Celcius to Fahrenheit:"+Fahrenheit);

    }
    }

    ReplyDelete
  48. Q.)WAP to calculate electricity bill where unit price and total consumption will be assigned by the users?

    Program:
    class Bill {
    public static void main(String[] args) {
    int unit_price=4,total_consumption=250,amount;
    amount=unit_price*total_consumption;
    System.out.println("Amount to be paid - "+amount+" Rs.");
    }
    }

    ReplyDelete
  49. WAP to calculate the multiplication of complex numbers?
    Program:
    class Complex_number{
    public static void main(String[] args) {
    int a=6,b=4,c=5,d=6,real,imaginary;
    real=a*c-b*d;
    imaginary=a*d+b*c;
    System.out.println("complex numbers - "+a+"+"+b+"i\t"+c+"+"+d+"i");
    System.out.print("sum = "+real+"+"+imaginary+"i");
    }
    }

    ReplyDelete
  50. Program to perform the addition of complex numbers?
    Program:

    class Complex_number{
    public static void main(String[] args) {
    int a=2,b=4,c=5,d=6,real,imaginary;
    real=a+c;
    imaginary=b+d;
    System.out.println("complex numbers - "+a+"+"+b+"i\t"+c+"+"+d+"i");
    System.out.print("sum = "+real+"+"+imaginary+"i");
    }
    }

    ReplyDelete
  51. WAP to find middle numbers using three-digit numbers?
    Program:

    class Middle_number {
    public static void main(String[] args) {
    int a=457,temp=a;
    a=a/10;
    a=a%10;
    System.out.println("Middle number in "+ temp+" is "+a) ;
    }
    }

    ReplyDelete
  52. WAP to find the maximum number in any three-digit number?
    Program:
    int a= 457 ;
    class Maximum_num {
    public static void main(String[] args) {
    int a=457,temp=a,x,y,z;
    x=a%10;
    a=a/10;
    y=a%10;
    a=a/10;
    z=a%10;
    if(x>y&&x>z) {
    System.out.println("Maximum number in "+ temp+" is "+x) ;
    }
    else if(y>x&&y>z) {
    System.out.println("Maximum number in "+ temp+" is "+y) ;
    }
    else {
    System.out.println("Maximum number in "+ temp+" is "+z) ;
    }
    }
    }

    ReplyDelete
  53. WAP to calculate the area of a circle where pi will be constant and radius will be variable?
    Program:
    class Area_of_circle {
    public static void main(String[] args) {
    int radius=4;
    final double PI=3.1415;
    double area=PI*radius*radius;
    System.out.println("Area of circle of radius "+radius+" is "+area);
    }
    }

    ReplyDelete
  54. WAP to calculate simple interest using instance type variable?
    Program:

    class Simple_interest {
    int p=10000,r=2,t=2;
    double si=(double)p*r*t/100;
    public static void main(String[] args) {
    Simple_interest obj=new Simple_interest();
    System.out.println("Simple Interest = "+obj.si);
    }
    }

    ReplyDelete
  55. WAP to convert temperature from Celsius to Fahrenheit using static data members globally?
    Program:
    class Celsius_to_Fahrenheit {
    static double f,c=30.00;

    public static void main(String[] args) {
    f=(c*9/5)+32;
    System.out.println(f);
    }
    }

    ReplyDelete
  56. //WAP to calculate electricity bill where unit price and total consumption will be assigned by the users?

    class Bill
    {
    public static void main(String...args)
    {
    double unit_price=1.5,total_consump=1500;
    System.out.println("Electricity Bill is"+(unit_price*total_consump));
    }
    }

    ReplyDelete
  57. class Middle
    {
    public static void main(String args[])
    {
    int b,num=247;

    num=num/10;
    b=num%10;
    System.out.println(b);


    }}

    ReplyDelete
  58. class Complex_Multi
    {
    public static void main(String args[])
    {
    int r1=2,r2=5,im1=3,im2=6,r,im;
    r=r1*r2;
    im=im1*im2;
    System.out.println(r + "i" + im);




    }
    }

    ReplyDelete


  59. import java.util.Scanner;
    class Area
    {
    final static float pi=3.41F;
    public static void main(String args[])
    {
    float r,area;
    Scanner sc=new Scanner(System.in);
    System.out.println("enter radius");
    r=sc.nextFloat();
    area=pi*r*r;
    System.out.println(area);





    }


    }

    ReplyDelete
  60. import java.util.Scanner;


    class Simple_interest
    {

    float p,r,t,si;
    public static void main(String args[])
    {
    Simple_interest obj=new Simple_interest();
    Scanner sc=new Scanner(System.in);
    System.out.println("enter value of p");
    obj.p=sc.nextFloat();
    System.out.println("enter value of r");
    obj.r=sc.nextFloat();
    System.out.println("enter value of t");
    obj.t=sc.nextFloat();
    obj.si=(obj.p*obj.r*obj.t)/100;
    System.out.println(obj.si);




    }
    }

    ReplyDelete
  61. kinjal singh sirohiFebruary 3, 2021 at 1:04 AM

    //WAP to calculate electricity bill where unit price and total consumption will be assigned by the users?
    import java.util.Scanner;
    class Electricbill
    {
    public static void main(String args[])
    {
    Scanner sc= new Scanner(System.in);
    System.out.println("enter unit price");
    int a=sc.nextInt();
    System.out.println("enter total consumption");
    int b=sc.nextInt();
    System.out.println(a*b);
    }
    }

    ReplyDelete
  62. kinjal singh sirohiFebruary 3, 2021 at 1:30 AM

    //WAP to calculate salary where basic, ta, da, comm, pf,hra,no.ofleave will be assigned by the users?
    import java.util.Scanner;
    class Salaryuser
    {
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("enter basic");
    int basic=sc.nextInt();
    System.out.println("enter ta");
    int ta=sc.nextInt();
    System.out.println("enter da");
    int da=sc.nextInt();
    System.out.println("enter comm");
    int comm=sc.nextInt();
    System.out.println("enter pf");
    int pf=sc.nextInt();
    System.out.println("enter hra");
    int hra=sc.nextInt();
    System.out.println("enter no. of leaves");
    int leaves=sc.nextInt();
    System.out.println(basic+ta+da+comm+pf+hra);
    System.out.println(basic+ta+da+comm-pf+hra-leaves);
    }
    }


    ReplyDelete
  63. kinjal singh sirohiFebruary 3, 2021 at 1:34 AM

    //WAP to find middle numbers using three-digit numbers?

    class MiddleNo
    {
    public static void main(String args[])
    {

    int a,b,c,num=789;
    a=num%10;
    num=num/10;
    b=num%10;
    num=num/10;
    System.out.println(b);
    }
    }

    ReplyDelete
  64. kinjal singh sirohiFebruary 3, 2021 at 1:40 AM

    //WAP to calculate the area of a circle where pi will be constant and radius will be variable?

    import java.util.Scanner;
    class AreaCirclepir

    {
    public static void main(String[] args)
    {
    Scanner sc=new Scanner(System.in);
    final float pi=3.14f;
    System.out.println("Enter r");
    float r =sc.nextFloat();
    float area=pi*r*r;
    System.out.println("Area of circle is="+area);
    }
    }

    ReplyDelete
  65. -WAP to calculate the area of a circle where pi will be constant and radius will be variable?

    import java.util.Scanner;
    class AreaofCircle

    {
    public static void main(String[] args)
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter r");
    float r =sc.nextFloat();
    final float pi=3.14F;
    float area=pi*r*r;
    System.out.println("Area of circle is= "+area);
    }
    }

    ReplyDelete
  66. -WAP to calculate simple interest using instance type variable?

    class Interest
    {
    int p=1000;
    float r=2.2F,t=2.1F,si;
    public static void main(String args[])
    {
    Interest obj=new Interest();
    obj.si=(obj.p*obj.r*obj.t)/100;
    System.out.println("result is =" + obj.si);


    }



    }

    ReplyDelete
  67. -WAP to calculate the area of a circle where pi will be constant and radius will be variable?

    import java.util.Scanner;
    class Area
    {
    final static float pi=3.14F;
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter r");
    float r=sc.nextFloat();
    float area=pi*r*r;
    System.out.println("Area of circle is= "+area);
    }
    }

    ReplyDelete
  68. -WAP to multiply complex number

    class ComplexMul
    {
    public static void main(String args[])
    {
    int r1=5,r2=3,img1=2,img2=6;
    int r=r1*r2-img1*img2;
    int img=r1*img1+r2*img1;
    System.out.println("Real= "+r+" Imaginary= "+img+ " i");
    }
    }

    ReplyDelete
  69. -WAP to find middle numbers using three-digit numbers?

    import java.util.Scanner;
    class Middle
    {
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter 3 digit no: ");
    int num=sc.nextInt();
    int a=num%10;
    num=num/10;
    int b=num%10;
    System.out.println("Middle number is= "+b);
    }
    }

    ReplyDelete
  70. -WAP to find the maximum number in any three-digit number?

    import java.util.Scanner;
    class Max
    {
    public static void main(String args[])
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter 3 digit no: ");
    int num=sc.nextInt();
    int a=num%10;
    num/=10;
    int b=num%10;
    num/=10;
    int c=num;
    if(a>b)
    {
    if(a>c)
    System.out.println("Maximum number is= "+a);
    else
    System.out.println("Maximum number is= "+c);
    }
    else
    System.out.println("Maximum number is= "+b);
    }
    }

    ReplyDelete
  71. //WAP to find the maximum number in any three-digit number?
    import java.util.Scanner;
    class Max
    {
    public static void main(String abc[])
    {
    int num,temp,max=0;
    Scanner sc= new Scanner(System.in);
    System.out.println("enter three digit number");
    num=sc.nextInt();
    temp=num%10;
    num=num/10;
    int a=num%10;
    num=num/10;
    int b=num%10;
    if(temp>a)
    max=temp;
    if (a>b)
    max=a;
    if(b>a)
    max=b;
    System.out.println("the maximum number is" +max);

    }
    }

    ReplyDelete

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post