⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rationaltest.java

📁 题目:银行家算法 具体要求:屏幕提示:输入申请资源的进程和各资源数目
💻 JAVA
字号:
//program uses class Scanner
import java.util.Scanner;

public class RationalTest
{
	//main method begins program execution
    public static void main(String args[])
    {
    	//create Scanner to obtain input from command window
        Scanner input = new Scanner(System.in);

        //create Rational objects and call the constutors
        Rational u = new Rational(7 ,5 );
        Rational v = new Rational(3 ,8 );
 
        //input two numbers 
        System.out.printf(" the numerator and denominator of u is : ");
        int a = input.nextInt();
        int b = input.nextInt();
        u.set(a ,b);//call method set

         //input two numbers 
	    System.out.printf(" the numerator and denominator of v is : ");
        int c = input.nextInt();
        int d = input.nextInt();
        v.set(c ,d);//call method set

        Rational t = u.add(v); //call method add and construtor
        System.out.printf("u + v = ");
        t.print();//call method print

        Rational m = u.minus(v);//call method minus and construtor
        System.out.printf("u - v = ");
        m.print();//call method print

        Rational n =u.multiply(v);//call method multiply and construtor
        System.out.printf("u * v = ");
        n.print();//call method print

        Rational q =u.addition(v);//call method addition and construtor
        System.out.printf("u / v = ");
        q.print();//call method print

    }//end main

}//end class RationalTest

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -