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.
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 -
//(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
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 -
//(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.
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
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?
'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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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
|
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)
|
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...
| |
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
|
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>
|
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;
|
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",...
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |