Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program below encodes a number using the formula below with a secret key: encoded number = ( original number + key ) x 5

The program below encodes a number using the formula below with a secret key:
encoded number =(original number + key) x 5
#include
using namespace std;
// Your code for A2 should be inserted here
int main(){
Encoder eKey(123);
int encodedValue, decodedValue;
int value =31;
cout << "original value: "<< value << endl;
encodedValue = eKey.encode(value);
cout << "encoded value: "<< encodedValue << endl;
decodedValue = eKey.decode(encodedValue);
cout << "decoded value: "<< decodedValue << endl;
return 0;
}
Sample output:
original value: 31
encoded value: 770
decoded value: 31
Implement the Encoder class with the following:
(a) The class scope with appropriate access specifier labels. (2 marks)
(b) A private data member key (integer).(2 marks)
(c) A default constructor that initializes the value of key to 3.(4 marks)
(d) A constructor with ONE parameter, that initializes the value of key with the argument.
(4 marks)
(e) A public member function encode() that takes a number (integer) as parameter, and returns
the encoded number (integer) using formula above with the key value. (4 marks)
(f) A public member function decode() that takes a number (integer) as parameter, and returns
the decoded number (integer) using the key value. (4 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

Assess various approaches to understanding performance at work

Answered: 1 week ago

Question

Provide a model of performance management

Answered: 1 week ago