1 Write a function in C++ to find the factorial of a number (using while loop).
Develop a program called National_lottery that determines the winning lottery numbers. The program must use the rand function to produce six(6) random numbers between 0 & 49 & number must not repeat. The numbers are generated by a user by clicking a button called Generate six(6) numbers.
-Then use an appropriate pointer operator to print the addresses of the numbers in memory & must be expressed in hexadecimals.
-use the derefencing operatorto point to values contained within the addresses. Use the function sort with begin() & end() function.
-Then assign the values into an array called winning_numbers. Use the for statement or the initialiser list to initialise the numbers into the array. Search the winning_numbers for any two(2) array elements(subscripts) that give the sum of >= 80 when added together, if the numbers >= 80 are more than one(1) set, consider the biggest set to be the one chosen for draw
3 Create a class called 'TIME' that has three integer data members for hours, minutes and seconds, a constructor to initialize the object to some constant
value, member function to add two TIME objects, member function to
display time in HH:MM:SS format. Write a main function to create two
TIME objects, add them and display the result in HH:MM:SS format.
Write a program to create a class CIRCLE with one
field as radius, used to calculate the area of a Circle. Create another class
RECTANGLE used to calculate the area of the rectangle which is a subclass
of CIRCLE class. Use the concept of single inheritance such that the radius
of circle class can be re-used as length in rectangle class. Take necessary
data members and member functions for both the classes to solve this
problem. All the data members are initialized through the constructors. Show the result by accessing the area method of both the classes through the
objects of rectangle class.
2 (Multilevel Inheritance) Modify the program no. 1 as follows:
Derive a class named as BOX from RECTANGLE class. Take necessary
data & member functions for this box class to calculate the volume of the
box. All the data members are initialized through the constructors. Show the
result by accessing the area method of circle and rectangle and the volume
method of box class through the objects of box class.
Sample Run 1
Welcome to CS126 Mart!
Item Codes Description Price
100 Sweet ‘n Ripe Grapes 125.35
101 Crunchy Apples 52.20
109 Green Peas 25.75
Enter Code: 128
Invalid code. This program will exit.
Sample Run 2
Welcome to CS126 Mart!
Item Codes Description Price
100 Sweet ‘n Ripe Grapes 125.35
101 Crunchy Apples 52.20
109 Green Peas 25.75
Enter Code: 100
Sweet ‘n Ripe Grapes 125.35
Quantity -3
Invalid quantity