Wednesday, 1 April 2015

Exercise-11 : write a Java Program to swap digits from a given integer number. Use Constructor with parameter. Use necessary method and instance, if required.


class Bx
{
double width;
double height;
double depth;
Bx(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
double volume() {
return width * height * depth;
}
}
class BxDemo7 {
public static void main(String args[]) {
Bx mybox1 = new Bx(4, 7, 20);
Bx mybox2 = new Bx(8, 6, 30);
double ad;
ad = mybox1.volume();
System.out.println("Volume is " + ad);
ad = mybox2.volume();
System.out.println("Volume is " + ad);
}
}

Exercise-10 : write a Java Program to swap digits from a given integer number. Use Constructor with parameter. Use necessary method and instance, if required.

class Bx
{
double width;
double height;
double depth;
Bx(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
double volume() {
return width * height * depth;
}
}
class BxDemo7 {
public static void main(String args[]) {
Bx mybox1 = new Bx(4, 7, 20);
Bx mybox2 = new Bx(8, 6, 30);
double ad;
ad = mybox1.volume();
System.out.println("Volume is " + ad);
ad = mybox2.volume();
System.out.println("Volume is " + ad);
}
}

Exercise-9 : Write a Java Program to Count the Number of Vowels in a given string. Use Constructor, Instances and Method, if necessary. Do not use any parameter with Constructor.

package inheritence;
class inher
{
int m, n;
void display1()
{
System.out.println("Value of m n =" +m +" " +n);
}
}

class hasmot extends inher
{
int p;
void display2()
{
System.out.println("Valu of p =" + p);
}
void sum()
{
System.out.println("Sum of m n p =" +(m+n+p));
}
}
public class Inheritence {



public static void main(String[] args)
{
inher input=new inher();
hasmot input1=new hasmot();
input.m=40;
input.n=60;
System.out.println();
input1.m=20;
input1.n=30;
input1.p=50;
System.out.println("Value of mnp");
input.display1();
input1.display2();
System.out.println();
System.out.println("The result is=");
input1.sum();

}

Exercise-8 : Write a Java program to calculate the SUM and COUNT of Primes from a given range of numbers. Formatting required for the Input and Output statements. Use Method with Parameter and return value to the Main function.

package exx4;
class Bx{
int width,height;
int muti()
{   
return width*height;
}

void getvalue( int w, int h)
{
width = w;
height =h;   
}
}
public class Exx4 {
    public static void main(String[] args) {
         Bx ob1 = new Bx();
         Bx ob2 = new Bx();
         double value;
         ob1.getvalue(10,5);
         ob2.getvalue(20,4);
         value =ob1.muti();
         System.out.println("Result is secound " +value);
        
         value =ob2.muti();
         System.out.println("Result is secound " +value);
    }
   
}

Exercise-7 : Write a Java program to reverse an Integer number. After print the output, make the sum of all digits. Use Method. Do not use parameter. Return value from Method to the Main function.

package ex4;
import java.util.Scanner;
class reverse {
int sum = 0;
int getvalue()
{
return sum;
}
}
public class Ex4 {
    public static void main(String[] args) {
       
        Scanner h = new Scanner(System.in);
        reverse nm = new reverse();
        int m,rv=0,nber,sum=0;
        System.out.println("Plz enter the int number");
       
        m = h.nextInt();
        nber = m;
       
        while (nber!=0) {           
        rv = rv*10;
        rv = rv+nber%10;
        nber = nber/10;
        sum+=rv;       
        }
        System.out.println("Reverses " +rv);
        double result = nm.getvalue();
        System.out.println("These Reversed number is " +sum);
    }  
}

Exercise-6 : Write a Java Program to Solve/Calculate of a Simple Interest by given condition. Use Method to solve this issue. Do not use parameter and return value from Method.

import java.util.Scanner;
class benifit{

    int hi ,to,yr,ir;
   
    void display()
    {
    System.out.println("These result :"+((to*yr*ir)/100));
    }
}

public class Ex2 {   
    public static void main(String[] args) {
        benifit hh = new benifit();
        Scanner input = new Scanner(System.in);
        System.out.println("Plz enter your required code");
        hh.to = input.nextInt();
        hh.yr = input.nextInt();
        hh.ir = input.nextInt();
        hh.display();
    }
   
}

Exercise-5 : Design and Write a simple java class program which can perform all basic operation of a Calculator. Define necessary instance variable but do not use method.


import java.util.Scanner;

public class Ex1 {
   
    public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
       int a,b,sum;
      
       System.out.println("plz enter a digit ");
       
       a = input.nextInt();
       b = input.nextInt();     
      
      sum = a+b;
      System.out.println("addition result " +sum);
     
      sum = a-b;
      System.out.println("addition result " +sum);     
     
      sum = a*b;
      System.out.println("addition result " +sum);
     
      sum = a/b;
      System.out.println("addition result " +sum);
   
    }
   
}

Saturday, 7 February 2015

Exercise-4: How to use If Else Statement in Java Programming

package ifelse;
import java.util.Scanner;

public class Ifelse {
   
    public static void main(String[] args) {
       
        Scanner input = new Scanner(System.in);       
        System.out.print("Plz enter your digit number ");
       
        int value = input.nextInt();
       
        if(value>=20 && value <=25)
        {
            System.out.println("This is my choose value ");      
        }
        else
        {
            System.out.println("This is my not choose value ");
        }
    }
   
}

Exercise-3: How to use If Statement in Java Programming

package ifelse;
import java.util.Scanner;

public class Ifelse {
   
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int value;
        System.out.println("Plz enter your digit number ");
        value = input.nextInt();
        if(value>=20)
        {
            System.out.println("This is my choose value ");       
        }
       
    }
   
}

Exercise 2: Inputting and Echoing integer and string entered by user

package integerst;
import java.util.Scanner;


public class Integerst {
   
    public static void main(String[] args) {
       
        Scanner input = new Scanner(System.in);
        int serial;
        String content;
       
        System.out.print("Plz enter your serial ");
        serial = input.nextInt();
       
        System.out.print("Plz enter your content ");
        content = input.next();
       
       
        System.out.println("Your serial output:"+serial);
        System.out.println("Your content output:"+content);
       
    }
   
}

Exercise-1: Echoing words in Java

package pz;
public class Pz {
    public static void main(String[] args) {
        System.out.println("My name is Eng.(Md.Hasmot Ali)");
        System.out.println("This is my programming java");
        System.out.println("This is my blogspot");
        System.out.println("My university name AUB");
    }
  
}

Author Messages

 This is blogs my project programming Java language
Blogs provide an online space for reflective writing and commentary. Campus Pack blogs can be viewable by all students in the class and the instructor. Each student posts individual entries to the blog and the rest of the class can comment on their posts. In a Blackboard course campus pack blogs can be deployed for: 
Everybody plz help if these blogs worng talking.These site working running