Untitled
user_4344994
plain_text
2 years ago
2.1 kB
6
Indexable
import java.io.*; import java.util.*; public class Solution { static Scanner sc = new Scanner(System.in); static int arr[]; float bossSalary = 0; public void addSalary(float num){ bossSalary = bossSalary + num; } class PersonDefine{ int type; String name; float baseSalary; int numProduct; int numWork; public void input (int type){ switch(type){ case 1:{ name = sc.next(); baseSalary = sc.nextFloat(); numProduct = sc.nextInt(); float temp = numProduct*2; addSalary(temp); break; } case 2:{ name = sc.next(); baseSalary = sc.nextFloat(); numWork = sc.nextInt(); float temp = numWork*40; addSalary(temp); break; } case 3:{ name = sc.next(); break; } } } public float calculateSalary(){ switch(type){ case 1: return baseSalary + numProduct*5; // break; case 2: return baseSalary + numWork*100; // break; case 3: return bossSalary; // break; default: break; } return 0; } } public static void main(String args[]) { int a = sc.nextInt(); PersonDefine p[] = new PersonDefine[a]; for (int i = 0; i<=a;i++){ p[i].type = sc.nextInt(); System.out.println(p[i].name+':' +p[i].calculateSalary()); p[i].calculateSalary(); } System.out.println(" ssas"); } }
Editor is loading...