Prog help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bentsi
    New Member
    • Oct 2006
    • 2

    #1

    Prog help

    Hi I need help with h.w asignment. The result E836 NOT SHOWING.

    // week3home.cpp : Defines the entry point for the console application.
    //
    #include "stdafx.h"
    #include <iomanip>
    #include <iostream>
    using namespace std;
    int _tmain(int argc, _TCHAR* argv[])
    {
    //convert licence plate into code
    char a,b,c;
    int num;
    int sum;
    char p;
    cout << "Enter licence plate: ";
    cin >> a >> b >> c >> num;
    sum = a+b+c+num;
    //cout << "\n" << sum << endl;
    p = sum % 26; //f. Determine the 4th letter in the alphabet after the letter 'A': 4th letter after 'A' is ‘E.
    cout << "\nCar Rental code: " << p << " " << sum;
    return 0;
    }

    Enter licence plate: CPR 607
    Car Rental code: ♦ 836Press any key to continue

    Thanks alot.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It isn't clear what the logic behind

    p = sum % 26; //f. Determine the 4th letter in the alphabet after the letter 'A': 4th letter after 'A' is ‘E.

    is

    Actually it is terribly clear what the logic behind

    sum = a + b + c + num;

    is

    Comment

    Working...