473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help Please toloswer and to upper question

I did a simple program Passing garde and I have to be able to enter grades in lower or upper case but for some reason my code does not accepts the lowercase grades can someone help me please here is part of my code....

#include <cctype>
#include <iostream>
using namespace std;

// required for conversion to lowercase
class toLower {public: char operator()(char c) const {return tolower(c);}};
char getGrade()

{

char grade = 'Q'; // the default value
grade = tolower(grade);
while (true)

{
cout << "What is your grade? [A, B, C, D, F, or Q to quit]: ";
cin >> grade;
cin.ignore(1000, 10);
if (grade == 'A' || grade == 'B' || grade == 'C') break;
if (grade == 'D' || grade == 'F') break;
if (grade == 'Q' || grade == 'q') break;

cout << grade << " is not a valid grade. Try again..." << endl;

} // while
return grade;
} // getGrade
int main()
{
char grade;
Oct 28 '08 #1
1 1255
Laharl
849 Expert 512MB
Follow the execution of your code through an iteration and see where the case is actually changed. (Hint: It's not where it should be.)
Oct 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ben | last post by:
hello, i'm following an algorithm book and am stuck on an early excersise in it, not because of the c programming side of it or even the algorithm side of it, i don't think, but because of maths....
24
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as...
8
by: mesutalturk | last post by:
How do i convert the following C# code to Delphi? public static uint GenerateSiteID(string SiteName) { uint id = 0; char arr = SiteName.ToCharArray(); //Convert the sitename to a Char Array...
1
by: vv1 | last post by:
Write a C program for reading in a message string (with no blanks) and decoding the message. Store the decoded message in another string called outString. After decoding is complete, print...
7
by: gheissenberger | last post by:
HELP! Guy who was here before me wrote a script to parse files in Python. Includes line: print u where u is a line from a file we are parsing. However, we have started recieving data from...
10
by: CuTe_Engineer | last post by:
hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes ...
10
by: hyozan.ux3 | last post by:
I want to create a program that I type in a word. for example... chaos each letter equals a number.... A=1 B=20
2
Thekid
by: Thekid | last post by:
I had made a post about making a loop using letters instead of numbers and dshimer gave me this solution: for i in range(65,70): for j in range(65,70): for k in range(65,70): ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.