Hi guys, I've been trying to round my output but I dont seem to be able to. I googled it but I dont understand float and ceiling or how to work them into my code. I did find that a roundf command should exsist but I dont have that option. I am using visual express studio so I wasnt sure if that just didnt have that command. Any help is greatly appreciated. Thank you.
Code:
#include
<stdio.h>
#include
<stdlib.h>
#include
<math.h>
// function declarations
float
schoolgrade(float x, float y, float z);
float
useroutput(float CG, float HG, float MG, float FG);
int
main ()
{
// local declarations
float homework = 0;
float midterm = 0;
float finalexam = 0;
float finalgrade = 0;
int student = 0;
int studentID = 1;
printf(
"Enter total number of students \n");
scanf(
"%d" ,&student);
while(student > 0)
{
printf (
"Enter 3 grades for student %d\n", studentID);
scanf (
"%f %f %f",&finalexam, &midterm, &homework);
if (finalexam <= 100 && finalexam >= 0 && midterm <= 75 && midterm >= 0 && homework <= 120 && homework >= 0)
{
finalgrade = schoolgrade(finalexam, midterm, homework);
useroutput(finalexam, midterm, homework, finalgrade);
system (
"pause");
student--;
studentID++;
}
else
{
printf(
"Incorrect value entered \n");
}
}
}
float
schoolgrade(floatx, floaty, floatz)
{
float
CG = 0;
float
HG = 0;
float
MG = 0;
float
FG = 0;
FG = (
x/100) * .30;
MG = (
y/75) * .20;
HG = (
z/120) * .50;
CG = (FG + MG + HG) * 100;
return
CG;
}
float
useroutput(floata, floatb, floatc, floatd)
{
printf (
"Final exam was %f out of 100 \n", a);
printf (
"Medterm exam was %f out of 75 \n", b);
printf (
"Homework assignments were %f out of 120 \n ",c);
puts (
"---------------------------------------- \n");
printf (
"Grade is %f \n", d);
}