need help with homework... assigning grades

here is the homework:
Write a program that in which you provide 3 grade values (as literal values) and calculate the sum and average of the
grades. Store the 3 grades as variables that allow decimal points. Also, store the sum and average as variables that
also allow decimal points. Finally, store the number of grades (3) in yet another variable whose data type should ONLY
supports whole numbers (no fractional component).

Your program should display only the average and sum of the grades and include meaninful output such as "The aveage grade is:"

Carefully think about data types of your variables. Do grades need to support negative values? What are max values
for grades? (Think container size) What about the variable that stores the number of grades? Does it need to support negative numbers or
numbers with a fractional component? You should declare variables of like data types using a single statement.
You should declare and initialize your variable that holds the number of grades using a SINGLE statement.
You will also be asked to create a variable to hold the earned letter grade. For now, you don't need to use any logic
to assign the grade earned. You can simply hard-code the value.

Finally, your program must include comments.

1. 3 varaiables in which you supply 3 grade values
2. A variable that holds the number of grades (3 in this case)
3. A variable that holds the sum of the 3 grades
4. A variable that holds the average of the 3 grades
5. A variable that holds character grade earned (A, B, C, ...)
6. Display the average grade and the letter grade using using a single cout statement
7. Display the output and make sure that the console window is preserved until you hit <cr>!

here is what I have for code so far:
#include "stdafx.h" // Needed for Visual C++ Express 2010
#include <iostream>
using namespace std;

int main()
double grade1;
double grade2;
double grade3;
double total;
double average;

grade1 = 85.5;
grade2 = 97.0;
grade3 = 86.9;
total = grade1 + grade2 + grade3;
average = total / 3.0;
cout << "The average grade is " << average << endl;
cin.ignore(); // needed for Visual C++ Express 2010

return 0;
wat about outputing the total grade?

Sorry this is my first time taking a c++ class what do you mean by outputting the total grade
Your program should display only the average and sum of the grades

As the question states, you can use the standard output stream, cout to output your variable, "total".

2. A variable that holds the number of grades (3 in this case)

you could use an int maybe const one, and initialize it to 3, as the question states.
so: const int num_of_grades=3;
5. A variable that holds character grade earned (A, B, C, ...)

are you allowed to use arrays, then an array of chars would be perfecr.

I have yet to learn about array
ok, then i think you should make a char variable for each grade letter. eg:
char gradeA='A',gradeB='B'; //etc...

ok soo..
what do I change to total
and where do I inset const int num of grade

im sorry to bother you im such a nub
I'm not saying change total. I am just saying output the value of total, like this: cout<<"The total grade is: "<<total;
and for the constant integer, you can declare it right after declaring the doubles. Like this:
double average;
const int num_of_grades=3;

You and your partner are IT consultants. You have been hired by a company/institution to write a C++ program OF A Pharmacy
You are required to create an executable individualized designed program with complete documentation in C++ to allow the companies/institutions to keep a record of all employees, customers/students and products/goods/services provided.
The program should have at least three classes involved, there must be at least one super-class, and must manipulate some collection using a file.
1. There must be a welcome screen that allows the users to:
o Add a new student/customer
o Add a new employee
o Add a new product
o Display all customers/students, employees and products
o Perform a calculation to determine the amount of school fee owed or compute a bill/invoice.
2. You must have a base class called Person, with member data: firstname, lastname, mi(middle initial), day of birth, month of birth and year of birth; and member functions getname, getDOB (allows user to input name and date of birth respectively) and an appropriate constructor function.
3. From this base class there should be derived classes for the various categories of persons in the organization with additional member data and member functions as you see fit.
4. There should be at least 15 students/customers, 5 teachers/tellers/workers and 15 products/course/services entered into the system. You need to create arrays of classes or use inked lists.
5. Comments must be included to describe what you are doing.

create a new thread.

Topic archived. No new replies allowed.