473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing code help

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 <stdio.h>
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 1440
gpraghuram
1,275 Expert 1GB
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 <stdio.h>
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
  1. //(A x .12) + (B x .28) + (C x .60) = Final Grade. 
  2. double final_grade = (v1 * .12) + (v2 * .28) + (v3*.60);
  3. //here v1,v2,v3 are the values entered by the user
  4.  
  5.  
Raghuram
Apr 1 '08 #2
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
  1. //(A x .12) + (B x .28) + (C x .60) = Final Grade. 
  2. double final_grade = (v1 * .12) + (v2 * .28) + (v3*.60);
  3. //here v1,v2,v3 are the values entered by the user
  4.  
  5.  
Raghuram

Is that the "ibase" command for storing the values entered?
What does that "double" signify?

Thanks.
Apr 1 '08 #3
gpraghuram
1,275 Expert 1GB
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
satch
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
'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
satch
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

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: lawrence | last post by:
I asked a lot of questions in May about how to organize OO code. I didn't get great answers here, but someone here suggested that I look the Eclipse library, which was a good tip. Looking at its...
4
by: George Stout | last post by:
First off I do not know alot about writing queries to an Access Database from an ASP page. This is why I need help. I have an Events database for 6 colleges in our metro area. On the homepage I...
9
by: 100 | last post by:
Has anybody read Steve Maguire's book "Writing solid code"? Do you think that the ideas in this book are not applicable in c# language? Does anybody find if(2 == i) istead of if(i == 2) as...
0
by: Gazelle | last post by:
I have a dilemma, that I am hopping I can find some help with. He is the back story so everyone sort of understands what it is that I am trying to accomplish. My problem: I have multiple...
4
by: Gary Bond | last post by:
Hi All, Can anybody point me to some 'how-to' documentation, tutorials, etc as to how to write a shrink/protect wrapper for .Net exes/dlls, (like the Shrinkwrap product for instance). I have...
3
by: localpricemaps | last post by:
i am having a problem writing a tuple to a text file. my code is below. what i end up getting is a text file that looks like this burger, 7up burger, 7up burger, 7up and this is instead...
1
by: Smita Prathyusha | last post by:
I am facing a problem in writing to COM1. I am using a Win 32 Console mode Program in VC++ the following is the code: If anyone can help me out it will be of great help : // SC_Using_Classes.cpp...
0
by: shintu | last post by:
Hallo, I am trying to write french accented characters é è ê in Excel worksheet using my perl script , But I am stuck here as I couldnt find a way of writing it !: My code: use strict;...
2
by: =?Utf-8?B?S3VtYXI=?= | last post by:
I am using granados telnet client for connecting to the telnet and get the data from it. Every thing appears to be going smooth. But for some reason when I try to write the byte data to a string or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.