can not get this to compile

Hi Newbie here! I'm writing a program and I get error messages and not sure what I am doing wrong. Please help!


// Headers
//#include"stdafx.h"
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>
using namespace std;

string getName();
void getAssignments(string[]);
void getGrades(int[], string[]);
double getAverage(int[]);
void displayMessage(string, int[], string[], double);

// This program is asking for the name of student
// 3 name assignments and grade for those assignments
// then to calculate those grades and to display with
// their name and decimal and to use a table

int main()
{
string name;
string assignment[3];
int grades[3];
double average;

// get the name of student


name = getName();

// Enter the name of assignments


getAssignments(assignment);


//Enter the grades for the three assignments they listed

getGrades(grades, assignment);

//Now lets average the grades of the three assignments

average = getAverage(grades);

// Display the average of your three assignments

displayMessage(name, grades, assignment, average);


cout << "May the odds be forever in your favor!" << endl;

return 0;
}
string getName()
{
string name;

cout << "Please enter your first and last name: ";
getline(cin, name);
return name;

}
void getAssignments(string assignment[])
{
string assignment;

cout << "Please enter the name of first assignment: ";
getline(cin, assignment[0]);
cout << "Please enter the name of second assignment: ";
getline(cin, assignment[1]);
cout << "Please enter the name to third assignment: ";
getline(cin, assignment[2]);
}
void getGrades(int grades[], string assignment[])
{
int grades;
string assignment;

cout << "Please enter the grade you recieved for " << assignment[0] << " : ";
cin >> grades[0];
cout << "Please enter the grade you recieved for " << assignment[1] << " : ";
cin >> grades[1];
cout << "Please enter the grade you recieved for " << assignment[2] << " : ";
cin >> grades[2];
}
double getAverage(int grades[])
{
int grades;

return (grades[0] + grades[1] + grades[2]) / 3.0;
}
void displayMessage(string name, int grades[], string assignment[], double average)
{
string name;
int grades;
string assignment;
double average;

cout << setprecision(1) << fixed;
cout << "The average for " << name << " is: " << average << '\n';
cout << "Here are your grades: \n" << setw(30) << assignment[0] << ": " << grades[0] << endl;
cout << setw(30) << assignment[1] << ": " << grades[1] << endl;
cout << setw(30) << assignment[2] << ": " << grades[2] << endl;
1
2
3
void getAssignments(string assignment[])
{
string assignment; // Why is this here? You already have something called "assignment" - the parameter you passed in 


You keep declaring some variables having the same name with the ones you pass to functions, change their name or remove if not necessary. And please use [code] [/code] tags.
Last edited on
Topic archived. No new replies allowed.