Main2.java
package pack_CustomClassBasic; public class Main2 { public static void main(String[] args) { int employedNum = 160; int graduatedNum = 245; EmployRate employRate = new EmployRate(employedNum, graduatedNum); double res = employRate.mtdCalc(); System.out.printf("취업률 : %.1f%%", res); } }
EmployRate.java
package pack_CustomClassBasic; public class EmployRate { int employedNum; // 취업자 수 int graduatedNum; // 졸업자 수 public EmployRate(int employedNum, int graduatedNum) { this.employedNum = employedNum; this.graduatedNum = graduatedNum; } public double mtdCalc() { double res = ((double)employedNum/graduatedNum) * 100; return res; } }