help me out please

Write your question here.
there are some questions in my code i need to apply some changes
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
  // Program Switches demonstrates the use of the Switch
// statement.

#include <iostream>
using namespace std;


int main ()
{
  char  letter;
  int  first;
  int  second;
  int  answer;


  cout << "Enter an A for addition or an S for"
       << " subtraction, followed by two integer numbers."

  cout << "Enter an A for addition or an S for"
       << " subtraction, followed by two integer numbers."
       << endl << "Press return.  Enter a Q to quit." << endl;
  cin >> letter;
  while (letter != 'Q')
  {
  cin >> letter;
  while (letter != 'Q')
  {
    cin  >> first  >> second;

    switch (letter)
    { 
      case 'A':           answer = (first + second);
                 cout << first  << " + "  << second
                 << " is "  << answer  << endl;
                 break;
      case 'B':      answer = (first - second);
                     cout << first << " - "  << second
                            << " is "  << answer  << endl;
                     break;
    }
    cin  >> letter;
  }
  return 0;
}


my questions are

1- add the code necessary to allow the program to work properly with both Lowercase and uppercase versions of the input letters?
2- add a default case that prints an error message and asks for the letter to be reentered?
1
2
3
4
5
6
7
8
9
10
11
12
13
switch(var)
{
        case 'A':
        case 'a':
                //do something
                break;
        case 'B':
        case 'b':
                //do something
                break;
        default:
                 //do something
}
// what is the wrong?

switches.cpp: In function `int main ()':
switches.cpp:25: `var' undeclared (first use this function)
switches.cpp:25: (Each undeclared identifier is reported only once for
each function it appears in.)
switches.cpp:36: parse error before `;'
switches.cpp:28: duplicate case value `'a''
switches.cpp:27: previously used here
switches.cpp:32: duplicate case value `'B''
switches.cpp:27: previously used here
switches.cpp:33: duplicate case value `'b''
switches.cpp:27: previously used here
there is something wrong
could you please write the codes again ? the whole prog.
Topic archived. No new replies allowed.