473,396 Members | 1,966 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,396 software developers and data experts.

how to calculate grade average in c++...plez help me!

2
a student wants to know his grade average for the semester. the grades are give in letter grades with numeric equivalents. develop a solution to calculate a grade average given the letter grades(the grade average is is figured per unit of credit!)
A=4.0
B=3.0
C=2.0
D=1.0
F=0.0
use a trip value to stop the processing of the loop and case structure to find the grade points
Mar 16 '08 #1
3 4854
oler1s
671 Expert 512MB
That’s a very common beginner programming assignment. Did you have a question?
Mar 16 '08 #2
hanie
2
That’s a very common beginner programming assignment. Did you have a question?
but i dont know how to use case structure.can you give me an example of it
Mar 16 '08 #3
but i dont know how to use case structure.can you give me an example of it
I will not solve it for you here, you need to learn how to use the many C++ references you have available. I looked up switch-case statement on Google using this query: " switch case statement +"C++" " and I got many pages of hits, most of which give a clear definition and usage for the switch-case statement.

One of the references I found gives a good example:
http://www.fredosaurus.com/notes-cpp/statements/switch.html

The key to using a switch-case statement is the case values must be immutable (constants) and not variables. For example:

Expand|Select|Wrap|Line Numbers
  1. int age, mary;
  2. char can_vote = FALSE;
  3.  
  4. switch (age) {
  5. case 16:
  6. case 15:
  7.     break;
  8. case mary:    // illegal case conditional, cannot be a variable
  9.     can_vote = TRUE;
  10.     break;
  11. case 'Q':
  12.     // the constant character Q was assigned to age
  13.     break;
  14. default:
  15.     break;
  16. } // end switch(age)
  17.  
The other mistake often made is forgetting to use the break statement between cases. In the example above, if age contained the value 16, control flow would fall into the statement for the case of 15, there was no break after the case to seperate them.

If, after trying the examples easily found by searching for the switch-case reference you have specific questions, feel free to ask.
Mar 16 '08 #4

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

Similar topics

2
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
1
by: sparkid | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
4
by: gaga | last post by:
hi guys, a part of my program requires me to calculate an average of items that are sold. the easiest way to do that would be writing a function, but im having trouble making up the parameters. if...
1
by: tonytj | last post by:
This program will read in studentID (3 digit integer number), three quizzes score, four assignments score and two tests scores. Each of the quizzes, assignments, and tests has up to 100 points. The...
11
by: C Learner | last post by:
I really need help I have got this program all screwed and cant figure out why I cant access my char grades pleade help C learner Grade.cpp int main(int argc, char *argv) { void...
3
by: paeh | last post by:
hello..can anyone help me. I am beginner in programming. I need to make a system that can calculate moving average. my system process will be executed according to certain schedule such as daily,...
1
by: shalit.dror | last post by:
I have an XML files that contains grades in different subjects from year 2005  2007 . In the HTML file I have several drop down list that contain all the names of the subjects. If I select for...
0
by: SuzK | last post by:
I am trying to calculate in VBA in Access 2002 a moving average and update a table with the calculations. Fields in my WeeklyData table are Week Ending (date) ItemNbr (double) Sales Dollars...
3
by: blamp | last post by:
I have completed most of the program I just cant get the letter grade to print from the void printGrade function.The output of the program should be: Line 1: Based on the course score, this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...
0
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...
0
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...

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.