Write a program that determines whether you can run for president. To run for president
the constitution states: No Person except a natural born Citizen, or a Citizen of the South
Africa(SA), at the time of the Adoption of this Constitution, shall be eligible to the Office
of President; neither shall any Person be eligible to that Office who shall not have
attained to the Age of thirty five Years, and been fourteen Years a Resident within the
South Africa. Ask three questions of the user and use the guess and check pattern to
determine if they are eligible to run for President.
The sum of the first n positive integers can be computed by the formula
sum(1..n) = 1 + 2 + 3 + 4 + · · · + n = n(n + 1)/2
Write a short Python program that computes the sum of the first 100 positive integers
and prints it to the screen, using format specifiers when printing instead of converting
each item to a string. Use variables to represent the 1, the 100, and the result of the
computation. Your program must compute the 5050 value. You cannot just print the
result to the screen. You must compute it first from the 100. The goal is for the output to
look exactly the same.The output is as shown below:
sum(1..100) = 5050
Company ABC in Kenya pays its employees based on a commission of the sales they make as
illustrated in the table below:
Monthly Sales Commission Rate
First 50,000 10%
Next 100,000 15%
Next 200,000 20%
Above 350,000 25%
Additionally, all employees are entitled to a basic commission of 20,000 per month.
a. Draw a flowchart that allows a HR employee to input an employee’s monthly sales,
computes the commission due to the employee and displays it to the HR employee.
[7 Marks]
b. Write a C++ program implementation of the flowchart above. [8 Marks]
Instructions
Input
The first line contains the size of the array/list.
The next lines contains an integer on each.
5
5
34
3
23
10Output
A line containing an integer.
34Company ABC in Kenya pays its employees based on a commission of the sales they make as
illustrated in the table below:
Monthly Sales Commission Rate
First 50,000 10%
Next 100,000 15%
Next 200,000 20%
Above 350,000 25%
Additionally, all employees are entitled to a basic commission of 20,000 per month.
a. Draw a flowchart that allows a HR employee to input an employee’s monthly sales,
computes the commission due to the employee and displays it to the HR employee.
[7 Marks]
b. Write a C++ program implementation of the flowchart above. [8 Marks]
Given the following array of 8 integers {2,3,2,1,2,5,8,2} you are required to write a C++ program that will loop through it and re-arrange it into the following final output {5,3,1,8,2,2,2,2} and display it . The idea is to position all values equal to 2 in the array to come after the other values not equal to 2. The order of the other values i.e 5,1,3 and 8 does not matter as long as they appear positioned before all 2s as illustrated in the hint below: Initial array: {2,3,2,1,2,5,8,2} NumbertoMove = 2 Final Array: {5,3,1,8,2,2,2,2} Write an algorithm as a pseudocode to solve the problem above.
Define exception handling in your own words then justify, using at least four examples of pre‐ defined system exceptions. (10 marks)
To accomplish automated memory management, Oracle uses two initialisation parameters. Explain the two initialisation parameters used to accomplish memory management then provide an advantage of using automatic memory management over manual memory management (5 marks)
Discuss the various PL/ SQL scalar data types available to store specific kinds of data with the use of examples. (10 marks)
What can "GetLastError()" function do, explain?