Homework help

Hello everybody. I am new to C++ and this week I am stumped with my homework.
My homework this week is about writting a program that calculates the cost of babysitting. We have to use if statements to show the different output. My facilatator told us that it should not take us more than 60 lines of code. I have worked out the problem on paper and started to write the code. So far I have about 60 lines code and I am only about half way done. I am wondering if it is possible for the program to be 60 lines of less? I also need to use the <cctype> to convert user input to upper case but I keep on getting errors.

#inclde <cctype>

char famFriend;

cin >> toupper(famFriend);

> So far I have about 60 lines code and I am only about half way done.

First, get your program to work correctly. Once that is done, we can look at what can be done to make it shorter.



toupper(famFriend) is a prvalue (a 'pure' rvalue).
To read a value from cin, you need an lvalue
http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc05lvalue.htm

Convert famFriend to upper case after reading it.
1
2
3
char famFriend ;
cin >> famFriend ;
famFriend = toupper(famFriend) ;

I finally finished my code and I tested all the different cases. It seems to be working fine. Thank you for your assistance I will try that code and make the toupper() function work.
Topic archived. No new replies allowed.