Help with output and dash position
Oct 3, 2013 at 3:21am UTC
I need help, I need to output the string "ENGL 101 - College Writing Skills" in this format: "College Writing Skills (ENGL 101)".
I can not just write out the words, I need to use a formula to figure out the output. I need help because I keep running into errors on lines 21 and 22.
Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// The purpose of this program is to produce the class statistics.
#include <iostream>
#include <cmath>
using namespace std;
const string COURSE = "ENGL 101 - College Writing Skills" ;
const int SCORE_1 = 47;
const int SCORE_2 = 42;
const int SCORE_3 = 43;
const int SCORE_4 = 49;
int main()
{
int dashPos;
int courseDesc;
int descLen;
dashPos = COURSE.find(" - " );
courseDesc = COURSE.substr(dashPos +3, descLen);
descLen = COURSE.length() - COURSE.substr(0, dashPos);
cout << endl;
cout << "Course: " << dashPos;
cout << endl;
return 0;
}
Oct 3, 2013 at 4:02am UTC
Nevermind guys, I got it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int dashPos;
string courseDesc;
string courseId;
dashPos = COURSE.find(" - " );
courseId = COURSE.substr(0, dashPos);
courseDesc = COURSE.substr(dashPos +3, 33);
cout << endl;
cout << "Course: " << courseDesc << " (" << courseId << ")" ;
cout << endl;
No thanks to this forum though
Topic archived. No new replies allowed.