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

📄 5.13interfacetest.java

📁 JAVA程序设计的源代码
💻 JAVA
字号:
import java.io.*;
interface MyInterface    //定义一个接口
{
float x=34.5f;    //接口中的属性
float y=4.25f;
float total();    //接口中的方法
}
public class InterfaceTest implements MyInterface    //继承接口
{
float dollar,money;
InterfaceTest(float a,float b)
{
dollar=a;
money=b;
}
public float total()    //实现接口中的方法
{
return x*dollar+money/y;    
}
public static void main(String args[])throws IOException
{
BufferedReader keyin=new BufferedReader(new InputStreamReader(System.in));
String st;
int n,m;
System.out.print("输入美金:");
st=keyin.readLine();    //输入一个整数
n=Integer.parseInt(st);
System.out.print("输入日元:");
st=keyin.readLine();    //再输入一个整数
m=Integer.parseInt(st);
InterfaceTest z=new InterfaceTest(n,m);
System.out.println("美金="+z.dollar);
System.out.println("日元="+z.money);
System.out.println("折合台币="+z.total());
}
}

⌨️ 快捷键说明

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