448,614 Members | 1,620 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,614 IT Pros & Developers. It's quick & easy.

Writing code help

 P: 11 Hi guys, I'm having a little difficulty and kind of stuck writing this particular code for a grade calculator project. I'm using linux OS. So far, i have: #include int man() { int my grade; /* user's grade */ printf ("welcome....."); printf("Enter HW1 score (out of 100"); printf("Enter HW2 score (out of 100"); printf("Enter HW3 score (out of 100"); printf("Enter Proj1 score (out of 100"); printf("Enter Proj2 score (out of 100"); printf("Enter Proj3 score (out of 100"); printf("Enter Proj4 score (out of 100"); printf("Enter Exam1 score"); printf("Enter Exam2 score"); printf("Enter Exam3 score"); Then im stuck. My question is, lets say i give the avg score of HW= A, and Proj = B and Exam= C. Given that HW= 12% of grade, Proj=28% and Exam=60%. So final equation is: (A x .12) + (B x .28) + (C x .60) = Final Grade. -How can i input that equation into the code inorder for it to compile and give me that final grade? -Are there any necessary loops to use? I extremely appreciate your help. Thanks. Apr 1 '08 #1
6 Replies

 Expert 100+ P: 1,275 Hi guys, I'm having a little difficulty and kind of stuck writing this particular code for a grade calculator project. I'm using linux OS. So far, i have: #include int man() { int my grade; /* user's grade */ printf ("welcome....."); printf("Enter HW1 score (out of 100"); printf("Enter HW2 score (out of 100"); printf("Enter HW3 score (out of 100"); printf("Enter Proj1 score (out of 100"); printf("Enter Proj2 score (out of 100"); printf("Enter Proj3 score (out of 100"); printf("Enter Proj4 score (out of 100"); printf("Enter Exam1 score"); printf("Enter Exam2 score"); printf("Enter Exam3 score"); Then im stuck. My question is, lets say i give the avg score of HW= A, and Proj = B and Exam= C. Given that HW= 12% of grade, Proj=28% and Exam=60%. So final equation is: (A x .12) + (B x .28) + (C x .60) = Final Grade. -How can i input that equation into the code inorder for it to compile and give me that final grade? -Are there any necessary loops to use? I extremely appreciate your help. Thanks. You can have the formula in the code itself. First you need to storethe values entered by the user. You can multiply the input entered by the user and do the sum and then print the output. like this Expand|Select|Wrap|Line Numbers //(A x .12) + (B x .28) + (C x .60) = Final Grade.  double final_grade = (v1 * .12) + (v2 * .28) + (v3*.60); //here v1,v2,v3 are the values entered by the user     Raghuram Apr 1 '08 #2

 P: 11 You can have the formula in the code itself. First you need to storethe values entered by the user. You can multiply the input entered by the user and do the sum and then print the output. like this Expand|Select|Wrap|Line Numbers //(A x .12) + (B x .28) + (C x .60) = Final Grade.  double final_grade = (v1 * .12) + (v2 * .28) + (v3*.60); //here v1,v2,v3 are the values entered by the user     Raghuram Is that the "ibase" command for storing the values entered? What does that "double" signify? Thanks. Apr 1 '08 #3

 Expert 100+ P: 1,275 Is that the "ibase" command for storing the values entered? What does that "double" signify? Thanks. since you multiply all the variables by a float value i have gone for double Raghu Apr 1 '08 #4

 P: 23 Is that the "ibase" command for storing the values entered? What does that "double" signify? Thanks. 'double' is a datatype like int and char. (Read about c++ datatypes and you'll find it.) Btw what is an ibase command? Apr 1 '08 #5

 P: 11 'double' is a datatype like int and char. (Read about c++ datatypes and you'll find it.) Btw what is an ibase command? i looked online for an example on what command to use to "store" values and all i could find was this command called "ibase". Could you provide me an example on how to write the command for storing values/integers? Thanks. Apr 1 '08 #6

 P: 23 i looked online for an example on what command to use to "store" values and all i could find was this command called "ibase". Could you provide me an example on how to write the command for storing values/integers? Thanks. So I think that what you want is a method to store user input in variable. In that case there is a function scanf using which you can store the values given by the user into variables. Read the documentation for scanf. Its similar to printf. Apr 16 '08 #7