there are 3 files but the one iam having problems with is the student.cpp
student.cpp -
#include <iostream> // for ostream << and istream >>
-
#include <string>
-
#include "student.h"
-
using namespace std;
-
-
//--constructors
-
-
student::student()
-
{
-
my_name = "?name?";
-
my_credits = 0.0;
-
my_qualityPoints = 0.0;
-
}
-
-
student::student(string initName, double initCredits, double initQualityPoints)
-
{
-
my_name = "initName,";
-
my_credits = initCredits;
-
my_qualityPoints = initQualityPoints;
-
}
-
-
//--modifiers
-
-
void student::completedCourse(double credits, double numericGrade)
-
{
-
my_credits = my_credits + credits;
-
my_qualityPoints = my_qualityPoints + (my_credits * numericGrade);
-
}
-
-
-
//--accessors
-
double student::GPA() const
-
{
-
my_qualityPoints / my_credits;
-
return;
-
}
-
string student::standing() const
-
{
-
if credits > 30
-
return “Freshman”;
-
if credits >= 30
-
return “Sophomore”;
-
if credits >= 60
-
return “Junior”;
-
if credits >=90
-
return “Senior”;
-
-
}
-
string student::name() const
-
{
-
Return my_name;
-
}
-
main.cpp -
#include <iostream>
-
#include <string>
-
#include "student.h" // this includs student.h
-
#include "compfun.h" // for decimals
-
-
using namespace std;
-
-
void display(student aStudent)
-
{
-
decimals(cout, 2);
-
cout << "{ student: " << aStudent.name();
-
cout << ", GPA = " << aStudent.GPA() << " }" << endl;
-
}
-
-
int main()
-
{ // test drivbe student: this main will vary a,mongst students
-
student aStudent("Nguyen", 36.5, 123.5);
-
student anotherStudent("Stella", 4.0, 16.0); // Straight A so far
-
student one ("one should be 3.0", 0.0, 0.0);
-
one.completedCourse( 4.0, 2.0 );
-
one.completedCourse( 4.0, 4.0 ); // 4 credit A
-
display( one );
-
display( aStudent );
-
display( anotherStudent );
-
-
// Finish branch coverage testing of standing
-
student two("two", 100.0, 30.0);
-
student three( "three", 30.05, 100.0 );
-
student four("four" , 60.0, 100.0 );
-
student five("five ", 60.05, 100.0);
-
student six ("six " , 90.0, 100.0);
-
student seven("seven", 90.05, 100.0 );
-
-
cout << one.standing() << endl;
-
cout << two.standing() << endl;
-
cout << three.standing() << endl;
-
cout << four.standing() << endl;
-
cout << five.standing() << endl;
-
cout << six.standing() << endl;
-
cout << seven.standing() << endl;
-
-
return 0;
-
}
-
-
- student.h
-
#ifndef STUDENT_H
-
#define STUDENT_H
-
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
-
class student {
-
public:
-
//--constructors
-
student();
-
// post: Initialize a student object with a name as "?name?,"
-
// 0.0 credits, and 0.0 quality points
-
-
student(string initName, double initCredits, double initQualityPoints);
-
// post: Initialize a student object with this 3 argument constructor
-
// student("Delaisio, Donna," 30.0, 120.0);
-
// A straight A sophomore at one school
-
-
//--modifier
-
void completedCourse(double credits, double numericGrade);
-
// post: record a completed course by adding credits to my_credits
-
// and incrementing the qualityPoints by (credits * numericGrade)
-
// aStudent.completedCourse(4.0, 3.67) // a 4 credit A- perhaps
-
-
//--accessors
-
double GPA() const;
-
// post: return the current grade point average as the accumulated
-
// quality points divided by the total number of credits.
-
-
string standing() const;
-
// post: use selection to return the current standing as either
-
// Freshman, Sophomore, Junior, or Senior.
-
-
string name() const;
-
// post: return the student's name
-
-
private:
-
string my_name;
-
double my_credits; // Total credits completed
-
double my_qualityPoints; // sum of credits multiplied by grades
-
};
-
-
#endif
-
-
4 1799 donbock 2,426
Recognized Expert Top Contributor
Please describe the problems you're having with student.cpp.
Oralloy 988
Recognized Expert Contributor
From a quick, simple inspection, I see the following two issues with student.cpp:
student::GPA() has a return statement with no value.
student::standi ng() has a code path which does not encounter a return statement.
Try resolving these issues and then give us a better description of the problems you're having.
Also, please use code tags. They makes reading source code sooooo much easier.
The first error I am getting is C2065: '“Freshman”‘: undeclared identifier. Any more help would be greatly appreciated, if you can’t tell I am new to this c++ programming and this summer class is killing me.
student.cpp -
#include <iostream> // for ostream << and istream >>
-
#include <string>
-
#include "student.h"
-
using namespace std;
-
-
-
-
student::student()
-
{
-
my_name = "?name?";
-
my_credits = 0.0;
-
my_qualityPoints = 0.0;
-
}
-
-
student::student(string initName, double initCredits, double initQualityPoints)
-
{
-
my_name = initName;
-
my_credits = initCredits;
-
my_qualityPoints = initQualityPoints;
-
}
-
-
//--modifiers
-
-
void student::completedCourse(double credits, double numericGrade)
-
{
-
my_credits = my_credits + credits;
-
my_qualityPoints = my_qualityPoints + (credits * numericGrade), credits * numericGrade;
-
}
-
-
-
//--accessors
-
double student::GPA() const
-
{
-
double results;
-
results = my_qualityPoints / my_credits;
-
return results;
-
}
-
string student::standing() const
-
{
-
-
if( my_credits < 30)
-
return “Freshman”;
-
if (my_credits >= 30)
-
return “Sophomore”;
-
if (my_credits >= 60)
-
return “Junior”;
-
if (my_credits >=90)
-
return “Senior”;
-
else
-
return 0;
-
}
-
string student::name() const
-
{
-
return my_name;
-
}
-
-
main.cpp -
#include <iostream>
-
#include <string>
-
#include "student.h" // this includs student.h
-
#include "compfun.h" // for decimals
-
-
using namespace std;
-
-
void display(student aStudent)
-
{
-
decimals(cout, 2);
-
cout << "{ student: " << aStudent.name();
-
cout << ", GPA = " << aStudent.GPA() << " }" << endl;
-
}
-
-
int main()
-
{ // test drivbe student: this main will vary a,mongst students
-
student aStudent("Nguyen", 36.5, 123.5);
-
student anotherStudent("Stella", 4.0, 16.0); // Straight A so far
-
student one ("one should be 3.0", 0.0, 0.0);
-
one.completedCourse( 4.0, 2.0 );
-
one.completedCourse( 4.0, 4.0 ); // 4 credit A
-
display( one );
-
display( aStudent );
-
display( anotherStudent );
-
-
// Finish branch coverage testing of standing
-
student two("two", 100.0, 30.0);
-
student three( "three", 30.05, 100.0 );
-
student four("four" , 60.0, 100.0 );
-
student five("five ", 60.05, 100.0);
-
student six ("six " , 90.0, 100.0);
-
student seven("seven", 90.05, 100.0 );
-
-
cout << one.standing() << endl;
-
cout << two.standing() << endl;
-
cout << three.standing() << endl;
-
cout << four.standing() << endl;
-
cout << five.standing() << endl;
-
cout << six.standing() << endl;
-
cout << seven.standing() << endl;
-
-
return 0;
-
}
-
-
- student.h
-
#ifndef STUDENT_H
-
#define STUDENT_H
-
-
#include <iostream>
-
#include <string>
-
using namespace std;
-
-
class student {
-
public:
-
//--constructors
-
student();
-
// post: Initialize a student object with a name as "?name?,"
-
// 0.0 credits, and 0.0 quality points
-
-
student(string initName, double initCredits, double initQualityPoints);
-
// post: Initialize a student object with this 3 argument constructor
-
// student("Delaisio, Donna," 30.0, 120.0);
-
// A straight A sophomore at one school
-
-
//--modifier
-
void completedCourse(double credits, double numericGrade);
-
// post: record a completed course by adding credits to my_credits
-
// and incrementing the qualityPoints by (credits * numericGrade)
-
// aStudent.completedCourse(4.0, 3.67) // a 4 credit A- perhaps
-
-
//--accessors
-
double GPA() const;
-
// post: return the current grade point average as the accumulated
-
// quality points divided by the total number of credits.
-
-
string standing() const;
-
// post: use selection to return the current standing as either
-
// Freshman, Sophomore, Junior, or Senior.
-
-
string name() const;
-
// post: return the student's name
-
-
private:
-
string my_name;
-
double my_credits; // Total credits completed
-
double my_qualityPoints; // sum of credits multiplied by grades
-
};
-
-
#endif
-
-
[/quote]
I am still having Problems getting the student.cpp to compile. the first errorIam getting is C2065: '“Freshman”' : undeclared identifier. Any more help would be greatly appreciated if you cant tell Iam new to this c++ programing and this summer class is killing me.
Oralloy 988
Recognized Expert Contributor
I'll assume that you're seeing that error at line 42 of student.cpp.
Looking at your code, it looks like your editor is putting balanced quotes in place of the C++ double quote.
Your code: - if( my_credits < 30)
-
return “Freshman”;
Probably should read - if( my_credits < 30)
-
return "Freshman";
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Greg Baker |
last post by:
I don't know what standard protocol is in this newsgroup. Am I allowed to
post code and ask for help? I hope so.. :)
Here's my problem: I am trying problem 127 of the valladolid online
contests (http://online-judge.uva.es/p/v1/127.html). The program I wrote
seems to work fine, but it takes way too much memory to run. I am not that
good at programming C++, unfortunately, so I can't seem to find my memory
leak. As far as I can tell,...
|
by: Boobie |
last post by:
this little ajax demo app here:
http://htmldb.oracle.com/pls/otn/f?p=25322:2
No complaint with FF - works as I intended.
But IE is not getting it.
e.g.
1) Last inserted element not getting fade effect but ALWAYS the first one.
2) Link on bottom does not delay appearance as I want.
|
by: Marc Bishop |
last post by:
I'm trying to get this to work but i'm at a loss as to how.
i've searched google without much help
code
Dim ArrCart As new ArrayList()
ArrCart = CType(Session("sesCart"), ArrayList)
ArrCart.add(sID & ",1")
Session("sesCart") = ArrCart
So what i want to do is maintain my Arraylist of items in a session.
|
by: James |
last post by:
Hello,
I'm trying to make a very simple shopping cart
using cookies and ASP. I want to store two
variables for each item in the cart (one for the
stock item, and one for its quantity).
How do I go about reading in a list of stock items
(variables) and their quantities?
|
by: B Williams |
last post by:
I have been working with this code for a better part of the day and I can't
figure out where I am making a mistake. I can only imagine it is when I
declare multiple paramaters on the constructor because the program compiles
with just one parameter. Can someone look at this and tell me where I made
my error?
This is the error I get while trying to compile.
error C2664: 'GradeBook::GradeBook(const GradeBook &)' : cannot convert...
| |
by: MQ.john |
last post by:
//Working Example:
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime; /* define rawtime as time_t */
time ( &rawtime );
|
by: siggi |
last post by:
Hi all,
as a newbie I have problems with formatting code of downloaded programs,
because IDLE's reformatting capabilities are limited . Incorrect
indentation, mixing of TAB with BLANKs or eol are often very nasty to
correct.
Is there a simple code formatter that first removes all indentations and
then refomats correctly?
Please help!
|
by: mikeguy3086 |
last post by:
Here is what I'm trying to achieve:
I'm making a site that is basically a big slide show which is insignificant, but it has to be really minimalistic. So what I did was make an invisible button that is over the entire 900x400 rectangle. Basically what I want and as far as I got was getting it so that when you scroll over the button, the blank menu drops down. And when you scroll off it retracts and goes back up. Here is my code
//this is...
|
by: Porkie999 |
last post by:
-----------------------------------------------------------------------QUESTION
hi i am really stuck with this and its only a small problem.
i want to be able to type .........
dsfsjfjsjjfs in User Box
fjdjskfjds in password box
www.thescripts.com in website box
then i want to have a button which says "save" which then saves the 3 above pieces of text into a notepad file.
So like I said I want to be able to type a login, password and...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
| |