SENTEINAL as char in a C++ code

I have a program that is to calculate the mean for a class into two parts , when is above 70 and the second is below 70.
I want to use SENTINEL to finish the program when the user enters n.
I did most of the code , but i still have more to do , please guide me through the rest .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

 int main()

        char  score;
        float total1;

        float total2;
        char  SENTINEL;
        float mean1=0;
        float mean2=0;
        float x;
        int count1=0;
        int count2=0;
        cout<<"Please enter a score, 'n' to finish"<<endl;
        cin>>score;

        while(score!='n')
        {

        while ((score>=0 )&&(score<=100))
        {
        if (score<70)
         {count1++;

        total1=total1+score ;

        }
        else
        total2=total2+score;
        }

        cout<<" Do you have more to enter?"<<endl;

if( SENTINEL != 'N' || SENTINEL != 'n')


         }
        mean1=total1/count1;
        mean2=total2/count2;


        cout<<mean1<<endl;
        cout<<mean2<<endl;

        return 0;
        }



Your program does not takes numbers. It takes characters and then threats it as numbers. Look up that table to understand it: http://www.asciitable.com/

To fix your program, say what should it do when user enters, say, 'x'? or '@'?
Do you say that I should compare the input to 110 , the decimal value of n?
No. I am saying that if you enter "10 20 n". your program will threat this as
49
48
50
48
end of input
Topic archived. No new replies allowed.