(i) A module is required to enable lecturers to easily identify the highest and lowest performing students in their courses. As the lead programmer, write a java program to achieve this. Your program should have the following features: Each correctly implemented feature earns you 3 marks. i. The program should make use of a sentinel to control the number of grades entered. ii. Total Number of grades entered iii. The average of the grades iv. Number of students that achieved a grade of 80 and above v. Number of students that achieved a grade of 50 and below
(ii) An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute. Write an algorithm for the implementation of the sentinel control in Question A Sub Question I above.
(iii) For larger datasets, a linear search may be inadequate or perhaps inefficient. What other search method can be employed to return the maximum number from a set of elements in an array. Explain your answer.
(i) Write a java program that reads three (3) int variables and performs the below operations: i. Prints out their product ii. Prints out the maximum of the numbers Do not use any inbuilt Java Methods to return the maximum. Extra marks will be awarded for clarity of code and comments. [8 marks]
(ii) Algorithms perform differently on different data sets and as such we may be interested in either their Best-case, Worst-case or Average-case scenarios. Explain why the Worst-case for an insertion sort is with reverse-sorted data. [6 marks]
(i) Identify and correct the errors in each of the following sets of code: [6 marks] i. while ( c <= 5 ) { product *= c; ++c; ii. if ( gender == 1 ) System.out.println( "Woman" ); else; System.out.println( "Man" ); iii. What is wrong with the following while statement? while ( z >= 0 ) sum += z;
(ii)Explain two (2) programming situations that will require the use of overloaded methods [5 marks]
(i) Identify and correct the errors in each of the following sets of code: [6 marks] i. while ( c <= 5 ) { product *= c; ++c; ii. if ( gender == 1 ) System.out.println( "Woman" ); else; System.out.println( "Man" ); iii. What is wrong with the following while statement? while ( z >= 0 ) sum += z;
(ii)Explain two (2) programming situations that will require the use of overloaded methods [5 marks]
Write a java program that reads three (3) int variables and performs the below operations: i. Prints out their product ii. Prints out the maximum of the numbers Do not use any inbuilt Java Methods to return the maximum. Extra marks will be awarded for clarity of code and comments. [8 marks]
B. Algorithms perform differently on different data sets and as such we may be interested in either their Best-case, Worst-case or Average-case scenarios. Explain why the Worst-case for an insertion sort is with reverse-sorted data. [6 marks]
Max Contiguous Subarray
Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list.
Input
The input will contain space-separated integers, denoting the elements of the list.
Output
The output should be an integer.
Explanation
For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,
[2]
[2, -4]
[2, -4, 5]
[2, -4, 5, -1]
[2, -4, 5, -1, 2]
[-4]
[-4, 5]
[-4, 5, -1]
[-4, 5, -1, 2]
[5]
[5, -1]
[5, -1, 2]
[-1]
[-1, 2]
[2]
Among the above contiguous sub-lists, the contiguous sub-list [5, -1, 2] has the largest sum which is 6.
Sample Input 1
2 -4 5 -1 2 -3
Sample Output 1
6
Sample Input 2
-2 -3 4 -1 -2 1 5 -3
Sample Output 2
7
Design a pay roll system to find the employee total salary using single inheritance. The base class employee consisting of data members such as emp_number and emp_name. The derived class salary consisting of data members such as Basic_pay, HRA, DA, PF, Net_pay.
Design the class Vowel to find the number of vowels present in the given string. Define the constructor member function to assign the values and destructor member function to destroy the data objects.
Define a class Fixed_Deposit with the following specifications, the program uses three overloaded constructors. The parameter values to these constructors are provided at run time. The user can provide input in the following forms.
1. Amount, period and interest in decimal form.
2. Amount, period and interest in percent form.
3. Amount and period.
PRIVATE DATA MEMBERS:
P_Amount long int type Years integer type Rate float type R_value float type
PUBLIC MEMBER FUNCTIONS:
Fixed_Deposit() Null constructor
Fixed_Deposit(p, y, r=0.12) Parameterized constructor with default arguments to accept values for P_Amount, Years and Rate(in Percent e.g., 0.12, 0.09)
Fixed_Deposit(p, y, r) Parameterized constructor with default arguments to accept values for P_Amount, Years and Rate(in Decimal e.g, 12%, 8%)
display() Function to display the P_Amount and R_Value
~Fixed_Deposit() Destructor to destroy the data objects
The Admission to a professional course is done using the following conditions.
a) Marks in Maths> =60
b) Marks in Physics >=50
c) Marks in chemistry >=40
d) Total in all the three subjects >=200 (or) Total in Maths and Physics >=150
Given the marks of three subjects, write a C++ program to process the applications to list the eligible candidates. [Note: Use call by value]