07. Scholarship
Здравйте! Малко помощ със една задача ми трябва, понеже не знам къде греша...
https://softuni.bg/trainings/resources/officedocument/35379/exercise-problem-descriptions-programming-basics-bulgaria-october-2018/2158
7-ма задача от линка.Ето и моето решение :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _07.Scholarship
{
class Program
{
static void Main(string[] args)
{
double income = double.Parse(Console.ReadLine());
double averageGrade = double.Parse(Console.ReadLine());
double minWage = double.Parse(Console.ReadLine());
double socialScholarship = 0.35 * minWage;
double scholarshipForExcellence = averageGrade * 25;
if(averageGrade <=4.50)
Console.WriteLine("You cannot get a scholarship!");
else if (averageGrade >4.50 && averageGrade <5.50 && income >=minWage)
Console.WriteLine("You cannot get a scholarship!");
else if(averageGrade>4.5&& averageGrade <5.5 && income<minWage)
Console.WriteLine("You get a Social scholarship {0} BGN", Math.Floor(socialScholarship));
else if (averageGrade>=5.5&&income<minWage&&socialScholarship<=scholarshipForExcellence)
Console.WriteLine("You get a scholarship for excellent result {0} BGN", Math.Floor(scholarshipForExcellence));
else if(averageGrade>=5.5&&income<minWage&&socialScholarship>scholarshipForExcellence)
Console.WriteLine("You get a Social scholarship {0} BGN", Math.Floor(socialScholarship));
else if(averageGrade>=5.5&&income>=minWage)
Console.WriteLine("You get a scholarship for excellent result {0} BGN", Math.Floor(scholarshipForExcellence));
}
}
}
Ще опитам ! Но, ако имаш решение можеш да го постнеш за сравнение :Д. Мерси !
Заповядай
namespace Scolarship
{
using System;
public class Program
{
static void Main(string[] args)
{
decimal income = decimal.Parse(Console.ReadLine());
double averageGrade = double.Parse(Console.ReadLine());
decimal minSalary = decimal.Parse(Console.ReadLine());
int gradeScolarship = 0;
int socialScolarship = 0;
if (averageGrade >= 5.5)
{
gradeScolarship = (int)Math.Floor(averageGrade * 25);
}
if (averageGrade > 4.5 && income < minSalary)
{
socialScolarship = (int)Math.Floor(0.35m * minSalary);
}
if (gradeScolarship == 0 && socialScolarship == 0)
{
Console.WriteLine("You cannot get a scholarship!");
}
else if (socialScolarship >= gradeScolarship)
{
Console.WriteLine($"You get a Social scholarship {socialScolarship} BGN");
}
else
{
Console.WriteLine($"You get a scholarship for excellent results {gradeScolarship} BGN");
}
}
}
}