Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace AnnualSalary
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int experience = int.Parse(Console.ReadLine());
- string specialty = Console.ReadLine();
- double salary = 0;
- if (specialty == "C# Developer")
- {
- salary = 5400;
- }
- else if (specialty == "Java Developer")
- {
- salary = 5700;
- }
- else if (specialty == "Front-End Web Developer")
- {
- salary = 4100;
- }
- else if (specialty == "UX / UI Designer")
- {
- salary = 3100;
- }
- else if (specialty == "Game Designer")
- {
- salary = 3600;
- }
- if (experience <= 5)
- {
- salary -= salary * 0.658;
- }
- Console.WriteLine($"Total earned money: {salary * 12:f2} BGN");
- }
- }
- }
- Решение с тернарен оператор:
- using System;
- namespace AnnualSalary
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int experience = int.Parse(Console.ReadLine());
- string specialty = Console.ReadLine();
- double salary =
- specialty == "C# Developer" ? 5400 :
- specialty == "Java Developer" ? 5700 :
- specialty == "Front-End Web Developer" ? 4100 :
- specialty == "UX / UI Designer" ? 3100 :
- specialty == "Game Designer" ? 3600 : 0;
- if (experience <= 5)
- {
- salary -= salary * 0.658;
- }
- Console.WriteLine($"Total earned money: {salary * 12:f2} BGN");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement