Question: ***This is a beginners C++ Program*** New Assignment: Your Class structure will be as follows: 1. Class name will be Egypt 2. The member variables
***This is a beginners C++ Program***
New Assignment:
Your Class structure will be as follows: 1. Class name will be Egypt 2. The member variables in your class will be: Int number which will hold the number to be checked. All the member variables are having public access specifier. 3. The member function present in your class will be: Void set_elements(int element): this function sets the given element to the member variable number Void get_element(): this function gets the member variable number. Print the number here. bool is_valid(): this function checks whether the given number is valid or not. Return True if number is valid or else return False.
void check (int number): this function prints open the chamber If condition holds good. It prints do not open the chamber if condition does not hold good. All your functions will have public access specifiers. The inputs for your program are same as Assignment 7. Create an object of type Egypt and do the following operations for each of the input. set_elements(int element) get_elements() check (int number) Make use of is_valid function accordingly to validate the number. Make sure that your code is well documented and indented. Also, all the submissions must in pdf format that are generated using the script process shown in lab containing the source code, compilation, and execution commands. Your program must run multiple times with having to execute it again.
Old Assignment (7) that is being referenced in new program:
The ancient land of Egypt holds a vast amount of secrets relating to wealth, scriptures and other unknown treasures. The trio of Rick, Evie and Jonathan have set out on one such adventure into the deserts of Egypt. On reaching one of the pyramids they find out that in order to open secret chambers present in these pyramids the ancient scholars have set keys to each of these chambers. The keys are evidently present at the entrance of the each of the chambers, but some of them are mines set to explode the entire pyramid upon entering the key. The trio come across a scripture that tells them that only those keys whose nth power of the sum of each of the digits equals the key are the ones which are valid keys. Here n is the number of digits present in the number.
Write a C++ program using functions (call by value, do not use call by reference) that takes in the key numbers and returns whether this key can help open the secret chambers or not. If the key is not the right one print a message Do not open the chamber. If the key is the right key, then print Open the chamber. You must write a function to validate the input, a function where you compute the logic and a function for printing. Input and Input Validation: The key will be all positive numbers. Any key that is negative or zero should not be computed. Sample Output and Explanation: Enter the key: 153 Open the chamber. The reason it is ok to open the chamber is because 13 + 5 3 + 33 = 153 Input Scenarios: Key = 370 Key = -5 Key = 4679307774 Key = 351 Key = 199091 Make sure that your code is well documented and indented. Also, all the submissions must in pdf format that are generated using the script process shown in lab containing the source code, compilation, and execution commands. Your program must run multiple times without having to run the program again.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
