Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: help with C++ code  (Read 2323 times)

0 Members and 1 Guest are viewing this topic.

EEVIAC

  • Guest
help with C++ code
« on: April 22, 2010, 09:01:23 AM »
I don't know if this is possible to do, the way I'm trying it, but I'll explain the best I can..


Code: [Select]

#include <iostream>
using namespace std;
int main()
{
const char Size = 20;
    char FirstName[Size];



enum grades {A, B, C, D, E};
    grades TEST;


cout << "What is your first name? ";
    cin.getline(FirstName, Size);
   
   
cout << "What is your last name? ";
char LastName;
cin >> LastName;


cout << "What letter grade do you deserve? ";
int TEST;
cin >> TEST;
    Actual_Grade = TEST + 1;


cout << "What is your age? ";
int age;
cin >> age;



cout << "Name:" << LastName << "," << FirstName << "\n";
cout << "Grade:" << Actual_Grade << "\n";
cout << "Age:" << age << "\n";
   
return 0;


}



I would like the output to be like this:


What is your first name? John Doe
What is your last name? Hanncock
What letter grade do you deserve? A
What is your age? 20
Name: Hanncock, John Doe
Grade: B
Age: 20


Notice in the output, how the "A" grade is incremented to "B"...  Basically, the user does not end up getting the grade he wants...  A practice assignment in my book asks to write a program that resembles the output above...

I just can't figure out how to make the "A" increment to one lower, which happens to be "B", in this case..   As I said, I don't know if this is possible to do the way I'm trying, but this is the code I've got so far..

I can't get it to compile, as is...

EEVIAC

  • Guest
Re: help with C++ code
« Reply #1 on: April 22, 2010, 09:06:30 AM »
I have no idea why I put this in the Networking forum.

Could someone please move it  :-X


Could someone please delete this post....
« Last Edit: April 22, 2010, 09:16:37 AM by EEVIAC »