Untitled

 avatar
user_4344994
plain_text
2 years ago
2.3 kB
6
Indexable
import java.io.*;
import java.util.*;

public class Solution {
    
    static Scanner sc = new Scanner(System.in);
    static PersonDefine 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 (){
            this.type = sc.nextInt();
            switch(this.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];
        PersonDefine arr[] = new PersonDefine[a];
        for (int i = 1; i<a; i++){
            // int temp = sc.nextInt();
            // arr[i].type = temp;
            arr[i].input();
            System.out.println(p[i].name+':' +p[i].calculateSalary());
            // arr[i] = sc.nextInt();
            // System.out.println(temp);

        }
        System.out.println("5");
  }
}
Editor is loading...