Java Programming

 

Java Programming

package its.a.program;


https://www.canva.com/join/kyn-rdk-hcb

Android Development
Android Development

Programm No.1

public class simpleProgramm {


  

    public static void main(String[] args) {

       

        System.out.println("Hey there........i am data!");

//printing name

        System.out.println("My name is Zahra Tayyaba  !");

        System.out.println("i am interested in java using android studio !");

        

    }

    

}

Program 2:




 
   
  
package its.a.program;


public class ItsAProgram {

  
    public static void main(String[] args)
 {
        
   for(int i=0; i<15; i++)   
{   
    for(int j=0; j<=i; j++)   
{   
    System.out.print("* ");   
}   
    System.out.println();        
}  


Programs No.3 

package its.a.program;


public class ItsAProgram {

  
    public static void main(String[] args) {
        
   for(int i=0; i<1; i++)   
{   
    for(int j=0; j<=i; j++)   
{   
     System.out.println("*****\n *** \n  *  \n *** \n*****");  
}   
    System.out.println();        
}

    
   
Program No .4
Sum of Numbers

TZ

Program 5:
Multiplication and Subtraction of Numbers:


Program No 6:
Simple Calculator in java:
How to take char /arithmatic operator from user in java:


package its.a.program;

import java.util.Scanner;


public class ItsAProgram {
//Calculator 
  
    public static void main(String[] args) {
    int a;
    int b;
    char ab;
    Scanner tz=new Scanner(System.in);
    System.out.println("Enter a num1 =");
    a=tz.nextInt();
    System.out.println("Enter a 2nd num =");
    b=tz.nextInt();
    System.out.println("Enter a operater");
    ab=tz.next().charAt(0);
        double addition  = a+b;
        double subtraction  = a-b;
        double multiplication  = a*b;
        double division  = a/b;

        switch(ab)
        {
            case '+' :
            {
                System.out.print("Total after Addition is : "+addition);
                break;
            }
            case '-' :
            {
                System.out.print("Total after Subtraction is : " +subtraction);
                break;
            }
            case '*' :
            {
                System.out.print("Total after Multiplication is : "+multiplication);
                break;
            }
            case '/' :
            {
                System.out.print("Total after Division is : "+division);
                break;
            }
            default :
            {
                System.out.print("Please select proper operator");
            }
        }
        
}
    
    


Program No 7:
Length and breadth of a rectangle are 5 and 7 respectively. Write a program to calculate the area and perimeter of the rectangle.

package its.a.program;

import java.util.Scanner;


public class ItsAProgram {

  
    public static void main(String[] args) {
        //find area and parameter
        int a=5;
        int b=7;
       int area=a*b;
        int parameter=(a+b)*2;
        System.out.println("area is ="+area+"\n parameterl is ="+parameter);
    }
        
}
Program No 8:

Print the ASCII value of the any character

package its.a.program;

import java.util.Scanner;


public class ItsAProgram {
    

  
    public static void main(String[] args) {
       //ascii value of h
        char a;
       System.out.println("Enter a any charater :");
       Scanner  t=new Scanner(System.in);
       a=t.next().charAt(0);
       int g=a;
       System.out.print("value of ASCII  "+a+"  is  " +g);
               
    }
        
}
    




    
    





Tags

Post a Comment

3 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.