noob C++ problem

Discussion in 'Web Design & Coding' started by dubstar, Mar 3, 2007.

  1. dubstar

    dubstar format c:

    Messages:
    1,357
    Location:
    Southern California
    i don't understand what i did wrong. i looked at the error checker but i dont really understand what it is saying...

    "
    1>gradecpp.cpp(96) : error C2146: syntax error : missing ';' before identifier 'endl'
    "

    but why would you need a semi colon before endl? ?? plus there is a problem with "
    if ( status = "FT" )
    {
    cout << "What is your GPA?" endl;
    cin >> gpa;
    }
    Code:
    [SIZE=2][COLOR=#008000]/*[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]******************************************[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]** Program name: GradeCheck *****[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]*** Date: March 02 2007 ****[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]**** Author: Alan Rosenquist ***[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]***** Description: Calcs GPA **[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]******************************************[/COLOR][/SIZE]
    [SIZE=2][COLOR=#008000]*/[/COLOR][/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Library[/COLOR][/SIZE]
     
    [SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]<iostream>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]#include[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]<string>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] std;[/SIZE]
     
    [SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] main()[/SIZE]
    [SIZE=2]{[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Header[/COLOR][/SIZE]
     
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t ****** * * ******* ***** ******* "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t* * * * * * * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t* * * * * ***** * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t* * * * * * * * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t ****** ****** ******* ****** * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Program name:"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Date: March 02 2007"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Author: Alan Rosenquist"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Description:"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2]<< endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Declaration of[/COLOR][/SIZE]
     
    [SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] id; [/SIZE][SIZE=2][COLOR=#008000]// student id number[/COLOR][/SIZE]
    [SIZE=2]string fname; [/SIZE][SIZE=2][COLOR=#008000]// students first name[/COLOR][/SIZE]
    [SIZE=2]string lname; [/SIZE][SIZE=2][COLOR=#008000]// students last name[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] cbis11; [/SIZE][SIZE=2][COLOR=#008000]// cbis11 score[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] cbis12; [/SIZE][SIZE=2][COLOR=#008000]// cbis12 score[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] cbis36; [/SIZE][SIZE=2][COLOR=#008000]// cbis 36 score[/COLOR][/SIZE]
    [SIZE=2]string status; [/SIZE][SIZE=2][COLOR=#008000]// full time or part time status in school[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] total; [/SIZE][SIZE=2][COLOR=#008000]// total sum of grades[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] average; [/SIZE][SIZE=2][COLOR=#008000]// total sum of grades divided by total number of grades[/COLOR][/SIZE]
    [SIZE=2]string grade; [/SIZE][SIZE=2][COLOR=#008000]// grade letter[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] gpa; [/SIZE][SIZE=2][COLOR=#008000]// grade point average[/COLOR][/SIZE]
    [SIZE=2]string message; [/SIZE][SIZE=2][COLOR=#008000]// grade message, triggered by A or F.[/COLOR][/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Input[/COLOR][/SIZE]
     
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your ID number? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for input id number[/COLOR][/SIZE]
    [SIZE=2]cin >> id; [/SIZE][SIZE=2][COLOR=#008000]// get id number[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your First name? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for first name[/COLOR][/SIZE]
    [SIZE=2]cin >> fname; [/SIZE][SIZE=2][COLOR=#008000]// get first name[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your Last name? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for last name[/COLOR][/SIZE]
    [SIZE=2]cin >> lname; [/SIZE][SIZE=2][COLOR=#008000]// get last name[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your CBIS 11 Score? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for cbis11 score[/COLOR][/SIZE]
    [SIZE=2]cin >> cbis11; [/SIZE][SIZE=2][COLOR=#008000]// get score[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your CBIS 12 Score? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for cbis12 score[/COLOR][/SIZE]
    [SIZE=2]cin >> cbis12; [/SIZE][SIZE=2][COLOR=#008000]// get score[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your CBIS 36 Score? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for cbis36 score[/COLOR][/SIZE]
    [SIZE=2]cin >> cbis36; [/SIZE][SIZE=2][COLOR=#008000]// get score[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Press FT for Full Time, or PT for Part Time "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask Fulltime or Parttime[/COLOR][/SIZE]
    [SIZE=2]cin >> status; [/SIZE][SIZE=2][COLOR=#008000]// get FT or PT[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( status = [/SIZE][SIZE=2][COLOR=#a31515]"FT"[/COLOR][/SIZE][SIZE=2] )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your GPA?"[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cin >> gpa;[/SIZE]
    [SIZE=2]}[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Process[/COLOR][/SIZE]
     
    [SIZE=2]total = ( cbis11 + cbis12 + cbis36 ) ; [/SIZE][SIZE=2][COLOR=#008000]// total class scores is all the scores added up[/COLOR][/SIZE]
    [SIZE=2]average = ( total / 3 ) ; [/SIZE][SIZE=2][COLOR=#008000]// average score is all the scores added, then divided by the number of classes.[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 60 )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"F"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 60, assign grade F[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 70 )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"D"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 70, assign grade D[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
    [SIZE=2]{ [/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 80 )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"C"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 80, assign grade C[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 90 )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"B"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 90, assign grade B[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average = 90, average > 90 )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"A"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is equal to 90, or above 90, assign grade A[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
     
     
     
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( gpa > 3.5 ) [/SIZE][SIZE=2][COLOR=#008000]// if GPA is greater than 3.5, congrats display message.[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]message = [/SIZE][SIZE=2][COLOR=#a31515]" \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]*************************************************** endl; \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* Comments: Congratulations on your achievements! * endl; \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* You Made The Dean's List!!!! * endl; \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]***************************************************"[/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( gpa < 2 ) [/SIZE][SIZE=2][COLOR=#008000]// if GPA is lower than 2, display warning message.[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]message = [/SIZE][SIZE=2][COLOR=#a31515]" \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]*************************************************** endl; \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* Comments: You need to be working MUCH harder!! * endl; \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* You are on Academic Probation * endl; \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]***************************************************"[/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Clear The Console Screen[/COLOR][/SIZE]
     
    [SIZE=2]system([/SIZE][SIZE=2][COLOR=#a31515]"cls"[/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000]// clear the screen before displaying results.[/COLOR][/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Output[/COLOR][/SIZE]
     
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" ----------------------------------------------------------------------- "[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Student Grading System (SGS)"[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Long Beach City College"[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Author: Alan Rosenquist"[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"March 2nd, 2007"[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"======================================================================="[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"ID #: "[/COLOR][/SIZE][SIZE=2] << id << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"First Name: "[/COLOR][/SIZE][SIZE=2] << fname << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Last Name: "[/COLOR][/SIZE][SIZE=2] << lname << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"\n"[/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Total Score: "[/COLOR][/SIZE][SIZE=2] << total << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Average Score: "[/COLOR][/SIZE][SIZE=2] << average << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Grade: "[/COLOR][/SIZE][SIZE=2] << grade << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Status: "[/COLOR][/SIZE][SIZE=2] << status << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Semester GPA: "[/COLOR][/SIZE][SIZE=2] << average << endl;[/SIZE]
    [SIZE=2]cout << message << endl;[/SIZE]
    [SIZE=2]cin >> endl;[/SIZE]
     
    [SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] 0;[/SIZE]
    [SIZE=2]}[/SIZE]
    
     
  2. GEN3RIC

    GEN3RIC Moderator Folding Team

    Messages:
    634
    Location:
    Woodbury, MN
    Dont worry, c++ is hell on your eyes. your solution is in bright red.

    Code:
     
    [COLOR=#0000ff]if[/COLOR][SIZE=2] ( status = [/SIZE][SIZE=2][COLOR=#a31515]"FT"[/COLOR][/SIZE][SIZE=2] )[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your GPA?" [/COLOR][COLOR=red][B]<<[/B][/COLOR][/SIZE][SIZE=2] endl;[/SIZE]
    [SIZE=2]cin >> gpa;[/SIZE]
    [SIZE=2]}[/SIZE]
     
     
  3. GEN3RIC

    GEN3RIC Moderator Folding Team

    Messages:
    634
    Location:
    Woodbury, MN
    Jeez that didnt even come close to compiling. I am glad I looked at it. This compiles - even though after you insert your GPA it exits the console. so I fixed that. just look over and compare your code and youll see where the errors lie.

    Code:
    [SIZE=2][COLOR=#0000ff]#include [/COLOR][/SIZE][SIZE=2][COLOR=#a31515]<iostream>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]#include [/COLOR][/SIZE][SIZE=2][COLOR=#a31515]<string>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]using [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] std;[/SIZE]
     
    [SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] main()[/SIZE]
    [SIZE=2]{[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Header[/COLOR][/SIZE]
     
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t ****** * * ******* ***** ******* "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t* * * * * * * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t* * * * * ***** * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t* * * * * * * * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t ****** ****** ******* ****** * "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Program name:"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Date: March 02 2007"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Author: Alan Rosenquist"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" \t * Description:"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2]<< endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Declaration of[/COLOR][/SIZE]
     
    [SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] id; [/SIZE][SIZE=2][COLOR=#008000]// student id number[/COLOR][/SIZE]
    [SIZE=2]string fname; [/SIZE][SIZE=2][COLOR=#008000]// students first name[/COLOR][/SIZE]
    [SIZE=2]string lname; [/SIZE][SIZE=2][COLOR=#008000]// students last name[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] cbis11; [/SIZE][SIZE=2][COLOR=#008000]// cbis11 score[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] cbis12; [/SIZE][SIZE=2][COLOR=#008000]// cbis12 score[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] cbis36; [/SIZE][SIZE=2][COLOR=#008000]// cbis 36 score[/COLOR][/SIZE]
    [SIZE=2]string status; [/SIZE][SIZE=2][COLOR=#008000]// full time or part time status in school[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] total; [/SIZE][SIZE=2][COLOR=#008000]// total sum of grades[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] average; [/SIZE][SIZE=2][COLOR=#008000]// total sum of grades divided by total number of grades[/COLOR][/SIZE]
    [SIZE=2]string grade; [/SIZE][SIZE=2][COLOR=#008000]// grade letter[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] gpa; [/SIZE][SIZE=2][COLOR=#008000]// grade point average[/COLOR][/SIZE]
    [SIZE=2]string message; [/SIZE][SIZE=2][COLOR=#008000]// grade message, triggered by A or F.[/COLOR][/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Input[/COLOR][/SIZE]
     
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your ID number? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for input id number[/COLOR][/SIZE]
    [SIZE=2]cin >> id; [/SIZE][SIZE=2][COLOR=#008000]// get id number[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your First name? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for first name[/COLOR][/SIZE]
    [SIZE=2]cin >> fname; [/SIZE][SIZE=2][COLOR=#008000]// get first name[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your Last name? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for last name[/COLOR][/SIZE]
    [SIZE=2]cin >> lname; [/SIZE][SIZE=2][COLOR=#008000]// get last name[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your CBIS 11 Score? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for cbis11 score[/COLOR][/SIZE]
    [SIZE=2]cin >> cbis11; [/SIZE][SIZE=2][COLOR=#008000]// get score[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your CBIS 12 Score? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for cbis12 score[/COLOR][/SIZE]
    [SIZE=2]cin >> cbis12; [/SIZE][SIZE=2][COLOR=#008000]// get score[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your CBIS 36 Score? "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask for cbis36 score[/COLOR][/SIZE]
    [SIZE=2]cin >> cbis36; [/SIZE][SIZE=2][COLOR=#008000]// get score[/COLOR][/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Press FT for Full Time, or PT for Part Time "[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// ask Fulltime or Parttime[/COLOR][/SIZE]
    [SIZE=2]cin >> status; [/SIZE][SIZE=2][COLOR=#008000]// get FT or PT[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (status == [/SIZE][SIZE=2][COLOR=#a31515]"FT"[/COLOR][/SIZE][SIZE=2])[/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"What is your GPA?"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cin >> gpa;[/SIZE]
    [SIZE=2]}[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Process[/COLOR][/SIZE]
     
    [SIZE=2]total = ( cbis11 + cbis12 + cbis36 ) ; [/SIZE][SIZE=2][COLOR=#008000]// total class scores is all the scores added up[/COLOR][/SIZE]
    [SIZE=2]average = ( total / 3 ) ; [/SIZE][SIZE=2][COLOR=#008000]// average score is all the scores added, then divided by the number of classes.[/COLOR][/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 60 ) {[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"F"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 60, assign grade F[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][SIZE=2] {[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 70 ) {[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"D"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 70, assign grade D[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][SIZE=2] { [/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 80 ) {[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"C"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 80, assign grade C[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][SIZE=2] {[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average < 90 ) {[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"B"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is less than 90, assign grade B[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][SIZE=2] {[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( average = 90, average > 90 ) {[/SIZE]
    [SIZE=2]grade = [/SIZE][SIZE=2][COLOR=#a31515]"A"[/COLOR][/SIZE][SIZE=2] ; [/SIZE][SIZE=2][COLOR=#008000]// if grade is equal to 90, or above 90, assign grade A[/COLOR][/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
     
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( gpa > 3.5 ) [/SIZE][SIZE=2][COLOR=#008000]// if GPA is greater than 3.5, congrats display message.[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]message = [/SIZE][SIZE=2][COLOR=#a31515]" \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]***************************************************\n \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* Comments: Congratulations on your achievements! *\n \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* You Made The Dean's List!!!! *\n \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]***************************************************"[/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ( gpa < 2 ) [/SIZE][SIZE=2][COLOR=#008000]// if GPA is lower than 2, display warning message.[/COLOR][/SIZE]
    [SIZE=2]{[/SIZE]
    [SIZE=2]message = [/SIZE][SIZE=2][COLOR=#a31515]" \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]***************************************************\n\[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* Comments: You need to be working MUCH harder!! *\n\[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]* You are on Academic Probation *\n \[/COLOR][/SIZE]
    [SIZE=2][COLOR=#a31515]***************************************************"[/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]}[/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Clear The Console Screen[/COLOR][/SIZE]
     
    [SIZE=2]system([/SIZE][SIZE=2][COLOR=#a31515]"cls"[/COLOR][/SIZE][SIZE=2]); [/SIZE][SIZE=2][COLOR=#008000]// clear the screen before displaying results.[/COLOR][/SIZE]
     
     
     
     
    [SIZE=2][COLOR=#008000]// Output[/COLOR][/SIZE]
     
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]" ----------------------------------------------------------------------- "[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Student Grading System (SGS)"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Long Beach City College"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Author: Alan Rosenquist"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"March 2nd, 2007"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"======================================================================="[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"ID #: "[/COLOR][/SIZE][SIZE=2] << id << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"First Name: "[/COLOR][/SIZE][SIZE=2] << fname << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Last Name: "[/COLOR][/SIZE][SIZE=2] << lname << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"\n"[/COLOR][/SIZE][SIZE=2] << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Total Score: "[/COLOR][/SIZE][SIZE=2] << total << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Average Score: "[/COLOR][/SIZE][SIZE=2] << average << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Grade: "[/COLOR][/SIZE][SIZE=2] << grade << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Status: "[/COLOR][/SIZE][SIZE=2] << status << endl;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Semester GPA: "[/COLOR][/SIZE][SIZE=2] << average << endl;[/SIZE]
    [SIZE=2]cout << message << endl;[/SIZE]
    [SIZE=2]cout << endl;[/SIZE]
    [SIZE=2]string quit;[/SIZE]
    [SIZE=2]cout << [/SIZE][SIZE=2][COLOR=#a31515]"Quit? Y/N\t"[/COLOR][/SIZE][SIZE=2];[/SIZE]
    [SIZE=2]cin >> quit;[/SIZE]
    [SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (quit == [/SIZE][SIZE=2][COLOR=#a31515]"Y"[/COLOR][/SIZE][SIZE=2]) {[/SIZE]
    [SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][SIZE=2] 0; [/SIZE]
    [SIZE=2]} [/SIZE]
    [SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][SIZE=2] {[/SIZE]
    [SIZE=2]system([/SIZE][SIZE=2][COLOR=#a31515]"cls"[/COLOR][/SIZE][SIZE=2]);[/SIZE]
    [SIZE=2]}[/SIZE]
    [SIZE=2]}[/SIZE]
    
     
  4. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    GEN3RIC: Don't give out full answers, people need to learn to read compiler errors to figure out what they did wrong. C++ is very easy to read properly indented and properly written.

    That one is a simple error that the compiler caught, and the human should have looked at line 96, look at endl, and looked to the front and to the back of it, and then figured out what is wrong. Compiler gave a clear warning!
     
  5. dubstar

    dubstar format c:

    Messages:
    1,357
    Location:
    Southern California
    thanks guys, i really appreciate it.

    x-istence: if it said "missing closing insertion operator" that would have been obvious, but for someone starting out, who adds code to they made a day ago, its easy to forget things.
     
    Last edited: Mar 3, 2007
  6. GEN3RIC

    GEN3RIC Moderator Folding Team

    Messages:
    634
    Location:
    Woodbury, MN
    I gave it to him because I have seen beginners struggle over the 38 errors I found. It would have taken me 2 days to elaborate each error cryptically so he could find them himself.

    I debated on not fixing it but telling him what's wrong, but its less helpful than you'd think.

    I am sure he appreciates what I did and will learn by his corrected example.
     
    dubstar likes this.
  7. GEN3RIC

    GEN3RIC Moderator Folding Team

    Messages:
    634
    Location:
    Woodbury, MN
    OH, and my opinion is that C++ is a mess to read. A lot of single character variables and less than verbose syntax makes it one of the hardest languages - save Java - for a beginner to read.
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Single character variables?

    Code:
    int i;
    is as valid as

    Code:
    int iterator;
    using single character variables is up to the programmer and has nothing to do with the language. Likewise much of the shorthand that is being used with the insertion operator can be done in a different way as well. Insertion operators are just in general easier to use for the programmer.

    Dubstar: How is the compiler to know what you want to do with the variable endl? For all it knows you want that as a separate segment of code. It can't guess what you as the programmer would want to do on that line. Remember the compiler can't deduce that you want to do something like we humans can. Now, that error is very helpful, as it is asking you to please put a semicolon on that line before the endl, if you went to the line to go make the compiler happy (thus placing a semicolon) you would have caught your own mistake easily.

    Trust me, get familiar with compiler errors, you will be dependent on them to write good code. Especially warnings it throws should be looked at under a magnifying glass, and only then should warnings get ignored if there is no way around it.
     
  9. dubstar

    dubstar format c:

    Messages:
    1,357
    Location:
    Southern California
    i refer back to this once in a while, helps a lot.

    thanks again!
     
  10. Sazar

    Sazar F@H - Is it in you? Staff Member Political User Folding Team

    Messages:
    14,905
    Location:
    Between Austin and Tampa
    I agree and disagree :(

    I happen to be partially color blind and believe me when I tell you, some of the color-coded errors simply slip my notice :(
     
  11. dubstar

    dubstar format c:

    Messages:
    1,357
    Location:
    Southern California
    color-coded? aw, now i know why my friend said this was a blue site and not a grey one.
     
  12. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    I personally don't have a syntax highlighter when I program. Everything is black and white. This also, once again was not something that would have been caught by syntax highlighting, so it does not pertain to why I said don't give out full answers.