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... ♥

javalinh

/*

 * 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