473,802 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing code help

11 New Member
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 1453
gpraghuram
1,275 Recognized Expert Top Contributor
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
marmar12
11 New Member
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 Recognized Expert Top Contributor
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 New Member
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
marmar12
11 New Member
'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 New Member
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
2237
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 small, simply objects was an education for me. What I was wondering, when I rewrote my cms from procedural code to OO was how to avoid end up have every class called by ever other? I was writing massive objects where every object needed every...
4
4048
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 have to display the next event for each college. That would give me 6 events listed on the page. I have been trying to figure out how to write a query statement in my ASP page to select just the most current event from each college. I have not had...
9
2939
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 unnetural and does it lead to more bugs in the code because of it makes programms hard to read. And my last question is: "Do you think that using boolean expressions
0
1749
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 users, each user has 2 or more CPU’s, using 3 or more monitors. 1 CPU system is running my web application. (Slick, high performance, and wonderful)
4
1771
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 got a couple of products nearly ready for sale, and have already come up with some routines to protect them, (in the style of the old TurboPower OnGuard), but really wanted to shrink and protect the exe's, so as to make reverse engineering a bit...
3
2758
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 of getting a list that should look like this
1
2974
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 : Defines the entry point for the console application. #include "stdafx.h" #include <stdio.h> #include <conio.h> #include <iostream>
0
2307
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; use warnings;
2
2172
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 streamwriter, it looses the final packet. Strangely, If I output the datapackets to a console from the telnet server, it perfectly gets all the output packets. the code snippet is below: StreamWriter sw = new StreamWriter("c:\\output.txt",...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.