[Programming Basics] Problem 04 - Trainers Salary
Здравейте ,
имам въпрос как се решава задача Problem 04 - Trainers Salary от Programming Basics Exam - 19 March 2017 - Morning. Java
Здравейте ,
имам въпрос как се решава задача Problem 04 - Trainers Salary от Programming Basics Exam - 19 March 2017 - Morning. Java
Това е моето решение на Java,ако имаш въпроси питай :)
package Demo;
import java.util.Scanner;
/**
* Created by Minito on 5/4/2017.
*/
public class DemoTrainers {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int n = Integer.parseInt(console.nextLine());
double salaryIn = Double.parseDouble(console.nextLine());
double salary = salaryIn / n;
double jelevSalary = 0.0;
double royalSalary = 0.0;
double roliSalary = 0.0;
double trofonSalary = 0.0;
double sinoSalary = 0.0;
double othersSalary = 0.0;
for (int i = 0; i < n; i++) {
String lectors = console.nextLine();
switch (lectors) {
case "Jelev" :
jelevSalary += salary;
break;
case "RoYaL" :
royalSalary += salary;
break;
case "Roli" :
roliSalary += salary;
break;
case "Trofon" :
trofonSalary += salary;
break;
case "Sino" :
sinoSalary += salary;
break;
default :
othersSalary += salary;
break;
}
}System.out.printf("Jelev salary: %.2f lv %nRoYaL salary: %.2f lv %nRoli salary: %.2f lv %n" +
"Trofon salary: %.2f lv %nSino salary: %.2f lv %nOthers salary: %.2f lv %n",jelevSalary,royalSalary,
roliSalary,trofonSalary,sinoSalary,othersSalary);
}
}
Благодаря ви много , успях да реша задачата .
За нищо лек ден :)