Chào các bạn! Vì nhiều lý do từ nay Truyen2U chính thức đổi tên là Truyen247.Pro. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

java

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package xulixau;

import java.util.Scanner;

public class Xulixau {

    public String xau;

    public Xulixau(String a)

    {

    xau=a;

    }

    public static int dem(Xulixau a)

    {

        return a.xau.length();

    }

    public static int demxh(Xulixau a,char b)

    {

        int dem=0;int j=0;

    for(int i=0;i<a.xau.length();i++)

    {

        if(a.xau.charAt(i)==b)

        {

        dem = dem+1;

        }

    }

    return dem;

    }

    public static void chuanhoa(Xulixau a)

    {

       // String xaus []=xau.split("");

          for(int i =0;i<a.xau.length();i++)

    {

     // xaus[i]=xaus[i].substring(0,1).toUpperCase().concat(xaus[i].substring(1).toLowerCase()+"");

     // xau=xau+xaus[i];

        a.xau=a.xau.replaceAll("  "," ");

        a.xau=a.xau.trim();

        //a.xau=a.xau.toUpperCase();

    }

//          return xau;

    }

    public static void In(Xulixau a)

    {

    System.out.println(a.xau);

    }

    public static void main(String[] args) {

        Scanner in=new Scanner(System.in);

        System.out.println("Nhap Xau Can Xu Ly:");

        String s=in.nextLine();

        Xulixau Z=new Xulixau(s);

        System.out.println("So Ki Tu Cua Xau");

        int j=Xulixau.dem(Z);

        System.out.println(j);

        System.out.println("nhap vao tu can tim");

        String x=in.nextLine();

        System.out.println("So Lan Xuat Hien Chua Ki Tu   "+x);

        char b=x.charAt(0);

        j=Xulixau.demxh(Z,b);

        System.out.println(j);

        System.out.println("Chuan Hoa Xau:");

        Xulixau.chuanhoa(Z);

        Xulixau.In(Z);

    }

}

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package classsophuc;

/**

 *

 * @author TUYETTHANGHAI

 */

import java.util.Scanner;

public class Classsophuc {

    /**

     * @param args the command line arguments

     */

    private double phanthuc;

    private double phanao;

   /* public Classsophuc(double pthuc, double pao) {

        phanthuc=pthuc;

        phanao=pao;

    }

      */       

    public void nhapsophuc(){

        Scanner in = new Scanner(System.in);

        System.out.println("Nhập phần thực: ");

        phanthuc=in.nextDouble();

        System.out.println("Nhập phần ảo: ");

        phanao=in.nextDouble();

    }

    public void insophuc(){

        if(phanao>0){

    System.out.print(phanthuc+"+"+phanao+"*i"+"

");

    }

        else

        {

            System.out.print(phanthuc+"-"+phanao+"*i"+"

");

        }

    }

    public Classsophuc congsophuc(Classsophuc a, Classsophuc b){

       Classsophuc c = new Classsophuc();

       c.phanthuc=a.phanthuc+b.phanthuc;

       c.phanao=a.phanao+b.phanao;

       return c;

    }

    public Classsophuc nhansophuc(Classsophuc a, Classsophuc b){

        Classsophuc c = new Classsophuc();

        c.phanthuc=a.phanthuc*b.phanthuc - a.phanao*b.phanao;

        c.phanao=a.phanthuc*b.phanao + a.phanao*b.phanthuc;

        return c;

    }

    public static void main(String[] args) {

        // TODO code application logic here

          Classsophuc a =new Classsophuc();

        Classsophuc b = new Classsophuc();

        Classsophuc c = new Classsophuc();

        a.nhapsophuc();

        b.nhapsophuc();

        System.out.println("số phức đã nhập là: ");

        a.insophuc();

        b.insophuc();

        System.out.println("Tổng là: ");

        c.congsophuc(a, b).insophuc();

        System.out.append("Tich là: ");

        c.nhansophuc(a,b).insophuc();

        /*int i,n;

        //int p[] = new int[100];

        Scanner in= new Scanner(System.in);

    System.out.println("nhap vao so phan tu cua mang ");

    n=in.nextInt();

    Classsophuc p[] = new Classsophuc[100];

    for (i=1;i<=n;i++){

        p[i].nhapsophuc();

        p[i].insophuc();

    }*/

    }

}

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package classphanso;

/**

 *

 * @author TUYETTHANGHAI

 */

import java.util.Scanner;

public class Classphanso {

    /**

     * @param args the command line arguments

     */

    public int tu;

    public int mau;

    public void phanso( int t, int m){

        tu=t;

        mau=t;

    }

    public void nhapphanso(){

        Scanner in = new Scanner(System.in);

        System.out.println("Nhập tử số: ");

        tu=in.nextInt();

        System.out.println("Nhập mẫu số: ");

        mau=in.nextInt();

    }

    public void inphanso(){

        System.out.println(tu+"/"+mau);

    }

    public void rutgonphanso(){

    }

public void sosanhphanso(Classphanso c, Classphanso d){

        c.mau=c.tu*d.mau;

        d.mau=c.mau*d.tu;

        if(c.tu>d.tu){

            System.out.println("Phân số "+c+ " lớn hơn phân số"+d);

        }

        else 

            if( c.tu==d.tu){

            System.out.println("Hai phân số bằng nhau");

        }

        else

            {

              System.out.println("Phân số "+d+ " lớn hơn phân số"+c);

            }

    }

    public static void main(String[] args) {

        // TODO code application logic here

        Classphanso a =  new Classphanso();

        Classphanso b= new Classphanso();

        Classphanso v =new Classphanso();

        a.nhapphanso();

        b.nhapphanso();

        a.inphanso();

        b.inphanso();

        v.sosanhphanso(a, b);

    }

}

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package classphanso;

/**

 *

 * @author TUYETTHANGHAI

 */

import java.util.Scanner;

public class Classphanso {

    /**

     * @param args the command line arguments

     */

    public int tu;

    public int mau;

    public void phanso( int t, int m){

        tu=t;

        mau=t;

    }

    public void nhapphanso(){

        Scanner in = new Scanner(System.in);

        System.out.println("Nhập tử số: ");

        tu=in.nextInt();

        System.out.println("Nhập mẫu số: ");

        mau=in.nextInt();

    }

    public void inphanso(){

        System.out.println(tu+"/"+mau);

    }

    public void rutgonphanso(){

    }

public void sosanhphanso(Classphanso c, Classphanso d){

        c.mau=c.tu*d.mau;

        d.mau=c.mau*d.tu;

        if(c.tu>d.tu){

            System.out.println("Phân số "+c+ " lớn hơn phân số"+d);

        }

        else 

            if( c.tu==d.tu){

            System.out.println("Hai phân số bằng nhau");

        }

        else

            {

              System.out.println("Phân số "+d+ " lớn hơn phân số"+c);

            }

    }

    public static void main(String[] args) {

        // TODO code application logic here

        Classphanso a =  new Classphanso();

        Classphanso b= new Classphanso();

        Classphanso v =new Classphanso();

        a.nhapphanso();

        b.nhapphanso();

        a.inphanso();

        b.inphanso();

        v.sosanhphanso(a, b);

    }

}

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

package classphanso;

/**

 *

 * @author TUYETTHANGHAI

 */

import java.util.Scanner;

public class Classphanso {

    /**

     * @param args the command line arguments

     */

    public int tu;

    public int mau;

    public void phanso( int t, int m){

        tu=t;

        mau=t;

    }

    public void nhapphanso(){

        Scanner in = new Scanner(System.in);

        System.out.println("Nhập tử số: ");

        tu=in.nextInt();

        System.out.println("Nhập mẫu số: ");

        mau=in.nextInt();

    }

    public void inphanso(){

        System.out.println(tu+"/"+mau);

    }

    public void rutgonphanso(){

    }

public void sosanhphanso(Classphanso c, Classphanso d){

        c.mau=c.tu*d.mau;

        d.mau=c.mau*d.tu;

        if(c.tu>d.tu){

            System.out.println("Phân số "+c+ " lớn hơn phân số"+d);

        }

        else 

            if( c.tu==d.tu){

            System.out.println("Hai phân số bằng nhau");

        }

        else

            {

              System.out.println("Phân số "+d+ " lớn hơn phân số"+c);

            }

    }

    public static void main(String[] args) {

        // TODO code application logic here

        Classphanso a =  new Classphanso();

        Classphanso b= new Classphanso();

        Classphanso v =new Classphanso();

        a.nhapphanso();

        b.nhapphanso();

        a.inphanso();

        b.inphanso();

        v.sosanhphanso(a, b);

    }

}

Bạn đang đọc truyện trên: Truyen247.Pro

Tags: #lili