Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 program using nested ifs
Index -> Programming, C -> C Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
stef_ios




PostPosted: Wed Jan 23, 2008 4:06 pm   Post subject: program using nested ifs

Hey all! So I am working on a C program that uses nested ifs. It asks the user to input four marks and based on the marks, it will calculate what the mark should be, and then display a grade level.

a)All the marks are out of 100, and are equally weighted in the average.
b)Grades are assigned based on A = 80 ? 100, B = 70 ? 79, C = 60 ? 69, D = 50 ? 59, F = 0 ? 49
c)If the student fails (i.e. mark < 50) either or both assignments, the grade is reduced by 1 (e.g. B becomes C).
d)If the student fails either or both tests, the mark will be F.

So I have done the program. I am having a problem with part c) though. Here is my program (done in Quincy99):


#include <stdio.h>
#include <math.h>

int
main(void)

{

double test1, test2, assignment1, assignment2;

printf("Please enter the first test mark: ");
scanf("%f", &test1);
printf("You entered: %f \n", test1);"

printf("Please enter the second test mark: ");
scanf("%f", &test2);
printf("You entered: %f \n",test2);

printf("Please enter the first assignment mark: ");
scanf("%f", &assignment1);
printf("You entered: %f \n", assignment1);

printf("Please enter the second assignment mark: ");
scanf("%f", &assignment2);
printf("You entered: %f \n", assignment2);

/* Now using nested ifs the program will use the calculate the average of the entered numbers and will
determine what the final mark is for the student */

if ((test1+test2+assignment1+assignment2)/4 == '100>80')
printf ("You got an A! \n");

else
if ((test1+test2+assignment1+assignment2)/4 == '79>70')
printf ("You got a B! \n");

else
if ((test1+test2+assignment1+assignment2)/4 == '69>60')
printf ("You got a C! \n");

else
if ((test1+test2+assignment1+assignment2)/4 == '59>50')
printf ("You got a D! \n");

else
if ((test1+test2+assignment1+assignment2)/4 == '49>0')
printf ("You got an F! \n");

else
if (test1,test2 == '50>0')
printf ("You got an F! \n");

else
if ((assignment1, assignment2) == '50>0')
printf ("You got a ! \n");

else
printf ("INVALID MARK! \n");

return (0);

}


So i'm not sure how to do part c) and also, how can I get my program to make sure none of the numbers inputed by the user are greater than 100 (100 is the maximum number that can be entered). Any help I can get would be great! Thanks! Very Happy
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C -> C Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: