Exercicios programação c
#include
#include
double round(double x)
{
return x < 0.0 ? ceil(x-0.5) : floor(x+0.5);
}
double round1( double x )
{
x = x*10; x =(ceil (x))/10; return x;
}
double weighted_average(double lab, double exam)
{
return lab * 0.4 + exam * 0.6;
}
double grade_exact(double lab, double exam)
{
return exam < 8.5 ? exam : weighted_average(lab, exam);
}
double grade_final(double lab, double exam) // acaba A
{
return round(grade_exact(lab, exam));
}
double weighted_average_with_quizzes(double lab, double exam, double quiz)
{
return lab * 0.35 + exam * 0.6 + quiz * 20 * 0.05;
}
double grade_exact_with_quizzes(double lab, double exam, double quiz)
{
return exam < 8.5 ? exam : weighted_average_with_quizzes(lab, exam, quiz);
}
double grade_final_with_quizzes(double lab, double exam, double quiz) // acaba B
{
return round(grade_exact_with_quizzes(lab, exam, quiz));
}
double weighted_average_without_lab(double exam, double quiz)
{
return exam * 0.95 + quiz * 20 * 0.05;
}
double grade_exact_new_rule(double lab, double exam, double quiz)
{
return lab < exam ? weighted_average_without_lab(exam, quiz): grade_exact_with_quizzes(lab, exam, quiz);
}
double grade_final_new_rule(double lab, double exam, double quiz) // acaba C
{
return round(grade_exact_new_rule(lab, exam, quiz));
}
double weighted_average_bizarre(double lab, double exam, double quiz) //E
{
return lab * 0.5 + exam * 0.75 + quiz * 20 * 0.1;
}
double grade_exact_bizarre(double lab, double exam, double quiz) //E
{
return exam < 8.5 ? exam : weighted_average_bizarre(lab, exam, quiz);
}
double grade_round_bizarre(double lab, double exam, double quiz) // E
{
return round(grade_exact_bizarre(lab, exam, quiz));
}
double grade_final_bizarre(double lab, double exam, double quiz) //E
{
double grade = 20; return