C++ program that will ask for a person’s name and out its magic number. How?

Create a program that will ask for a person’s name and out its magic number. (Refer to the table below)
The person’s magic number will be based on the person’s name. Each letter of the name corresponds to a number (refer to ascii value) Add the corresponding value and get the modulus division or 10.

Note: Use modulus division. Use Select Case Statement.

Name.............J.........u........a.........n
Ascii Value.....74......117.....97......110
......................J.........u........a.........n
......................74.......85......65......78

74+85+65+78 = 302
The modulus of 302 is 2

Example:

0 - you enjoy socializing and take on challenges just for fun. you are fickle-minded but are always ready to help someone in need.
1 - you are sure of yourself, make friends easily, and like to keep busy.
2 - you are quiet rather shy, and work easily with others.
3 - you are clever and artistic, and like to be with people.
4 - you are hardworking and dependable. you do not change your mind easily.
5 - you are smart, like to be active, and love adventure. but loose your temper easily.
6 - you are fair, unselfish, and careful of other people's feelings. you like to keep thing neat and organized.
7 - you like to be yourself and don't like to do what everyone else is doing. you think things out carefully.
8 - you like to plan things out and be sure you are right. you are kind hearted, and people know that they can trust you.
9 - you like people and you believe strongly in freedom. you are a clever thinker.



...Please help me with this. I'm using Bloodshed Dev-C++.
1. Upgrade to a more recent compiler. For instance http://sourceforge.net/projects/orwelldevcpp/

2. Read up on std::string
http://www.mochima.com/tutorials/strings.html

To read the name of the person, use std::getline()
http://www.cplusplus.com/reference/string/string/getline/

Access each character in the persons name with a range based for loop
for( char c : name ) { /* .... */ }
or with the subscript operator
for( std::size_t i = 0 ; i < name.size() ; ++i ) { char c = name[i] ; /* .... */ }
Topic archived. No new replies allowed.