C++ PROGRAMMING
The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5
Table 1- Machine "A" Production
Day 1 2 3 4
Array index 0 1 2 3
Production 15.5 25.5 27.5 60.5
Table 2- Machine "B" Production
Day 1 2 3 4
Array index 0 1 2 3
Production 50 45.5 25.5 18
Table 3- Machine "C" Production
Day 1 2 3 4
Array index 1 2 3 4
Production 35.5 65 71 74.5
1) Write a function using C++ statements called GetProduction() which takes a float array and an integer (as the day) as parameters. The function returns the production of that day.
C++ PROGRAMMING
The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5
Table 1- Machine "A" Production
Day 1 2 3 4
Array index 0 1 2 3
Production 15.5 25.5 27.5 60.5
Table 2- Machine "B" Production
Day 1 2 3 4
Array index 0 1 2 3
Production 50 45.5 25.5 18
Table 3- Machine "C" Production
Day 1 2 3 4
Array index 1 2 3 4
Production 35.5 65 71 74.5
1) Write a function using C++ statements called AverageProduction() which takes three float values (valuel , value2, value3 ) as parameters and returns the average production. 2)Write a function using C++ statements called TotalProduction() which takes three float values (valuel , value2, value3) as parameters and returns the total production.
C++ PROGRAMMING
The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5
Table 1- Machine "A" Production
1 2 3 4
Array index 0 1 2 3
Production 15.5 25.5 27.5 60.5
Table 2- Machine "B" Production
1 2 3 4
Array index 0 1 2 3
Production 50 45.5 25.5 18
Table 3- Machine "C" Production
1 2 3 4
Array index 1 2 3
Production 35.5 65 71 74.5
Write a function using C++ statements called PrintBar() which takes a float (as production) as a parameter. The function prints asterisks on the screen based on the production.
Note: I asterisk = 10 production units (round up the production units)
Example.
Sample Input
Machine A Day I Production 15.5
Sample Output
**
C++ PROGRAMMING
The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5
Table 1- Machine "A" Production
1 2 3 4
Array index 0 1 2 3
Production 15.5 25.5 27.5 60.5
Table 2- Machine "B" Production
1 2 3 4
Array index 0 1 2 3
Production 50 45.5 25.5 18
Table 3- Machine "C" Production
1 2 3 4
Array index 1 2 3
Production 35.5 65 71 74.5
(b) Write a function using C++ statements called MinimumMachine() which takes three float values (valuel, value2, vlaue3) as parameters and returns the machine that has the lowest production.
MinimumMachine returns A (represents machine A)
(c) Write a function using C++ statements called MaximumMachine() which takes three float values (valuel, value2, value3) as parameters and returns the machine that has the highest production.
Ex:
MaximumMachine (15.5,50,35.5) returns B (represents machine B)
C++ PROGRAMMING
The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5
Table 1- Machine "A" Production
1 2 3 4
Array index 0 1 2 3
Production 15.5 25.5 27.5 60.5
Table 2- Machine "B" Production
1 2 3 4
Array index 0 1 2 3
Production 50 45.5 25.5 18
Table 3- Machine "C" Production
1 2 3 4
Array index 1 2 3
Production 35.5 65 71 74.5
(a) Write a function using C++ statements called InputProduction() which takes a float array and an integer (as the size of the array) as parameters. The method should ask the user to insert production of each machine and fill the array. The values are entered through the keyboard and range between 15.5 and 75.5.
Write a function using C++ statements called PrintReport() which takes three float arrays (valuel, value2, value3) and an integer (as the size of the array) as parameters. The method prints the report as given below.
Sample Output:
Day Machine A Machine B Machine C Minimum Maximum Total Average
1 15.5 50 35.5 A B 101 33.66
2 25.5 45.5 65 A C 136 45.33
3 27.5 25.5 71 B C 124 41.33
4 60.5 18 74.5 B C 153 51
Note: Should use functions already defined to find minimum, maximum, total and average.
Create a class Date whose object can store a day, month and year. Include the necessary
constructors to initialize the objects and function to display the date in ‘dd/mm/yyyy’ format.
Define a non-member function findAge(Date dob, Date today) which should return the calculated
age from the input dates ‘dob’ and ‘today’. Set this function as friend to Date class. Write a main
function to read the today’s date and date of birth of a person from the user and display the age
of that person by calling the proper function.
Create a class called Transmitter. It has three unsigned int private data members: pay_load,
parity and data_packet; It has one function called parity_bit(). It calculates parity bit by XORing
all pay_load bits and assign the value to parity. By using function get pay_load(), pay_load is got.
data_packet is calculated by multiplying parity_bit with 32768 and add the product with (pay_load
– 32768). Create another class called Receiver. It has unsigned int private data members Rx_Pkt
, Rx_Data and E_Flag. Rx_Data is got from Rx_Data as given below. First E_Flag is calculated
from Rx_Pkt by XORing all bits. If E_Flag is zero, then Rx_Data = Rx_Pkt – 32768, Else a
message should warn about corrupted packet. Derive a class called Tranceiver from the above two
classes and check the functionalities. Use any other functions if needed.
Create a class called InputData. It has two private data members data_a and data_b. Set the
values of these two data members by using two public functions get_a() and get_b(). Derive a class
called Arith_Unit from InputData. It contains the functions add(),sub(), mul(),div() to perform
arithmetic operations on data_a and data_b. Derive a class Logic_Unit from InputData. It
contains the functions and(), or() and xor() to perform logical operations on data_a and data_b.
Finally derive a class called ALUnit from Arith_Unit and Logic_Unit classes. It has to perform
arithmetic and logical operations according to the given codes. Choose code 0 to code 6 to perform
the said seven operations. Write sample program to test the ALU class.
Write a program to create a class Date with day, month and year as members. Write a member
function to validate the dates and display the invalid dates. Test the class with an array of Date objects.