08.Scholarship
Здравейте, на тази задача изкарвам 93/100 точки в judge дали някой може да ме посъветва къде греша.
using System;
namespace SumSeconds
{
class Program
{
static void Main(string[] args)
{
double income = double.Parse(Console.ReadLine());
double avgScore = double.Parse(Console.ReadLine());
double avgSalary = double.Parse(Console.ReadLine());
double socialScholarships = avgSalary * 0.35;
double gradeScholarship = 25 * avgScore;
if (avgScore >= 5.50 && gradeScholarship >= socialScholarships)
{
Console.WriteLine($"You get a scholarship for excellent results {Math.Floor(gradeScholarship)} BGN");
} else if (income < avgSalary && avgScore > 4.50){
Console.WriteLine($"You get a Social scholarship {Math.Floor(socialScholarships)} BGN");
}
else
{
Console.WriteLine("You cannot get a scholarship!");
}
}
}
}
Ето и моето решение с 300 зора го докарах. Като гледах дори как го решава преподавател и пак бърках. Просто са твърде много вариантите за обхождане.
using System;
namespace Scholarship
{
class Program
{
static void Main(string[] args)
{
double income = double.Parse(Console.ReadLine());
double grade = double.Parse(Console.ReadLine());
double minimumSalary = double.Parse(Console.ReadLine());
double excelentScholarship = grade * 25;
double socialScholarship = minimumSalary * 0.35;
if (grade <= 4.50)
{
Console.WriteLine("You cannot get a scholarship!");
}
else if (grade > 4.50 && grade < 5.50)
{
if (income<minimumSalary)
{
Console.WriteLine($"You get a Social scholarship {Math.Floor(socialScholarship)} BGN");
}
else
{
Console.WriteLine("You cannot get a scholarship!");
}
}
else if (grade >= 5.50)
{
if (income<minimumSalary)
{
if (excelentScholarship > socialScholarship)
{
Console.WriteLine($"You get a scholarship for excellent results {Math.Floor(excelentScholarship)} BGN");
}
else
{
Console.WriteLine($"You get a Social scholarship {Math.Floor(socialScholarship)} BGN");
}
}
else
{
Console.WriteLine($"You get a scholarship for excellent results {Math.Floor(excelentScholarship)} BGN");
}
}
}
}
}