بسم الله الرحمن الرحيم
اخواني الكرام عندي اسئلة في c++
مش عارف احلها وعيلها 10 علامات بالجامعة
رجاااااااااااااء حد يساعدني
رجااااااااااااااء
Q1. Assume the class car has the following private attributes:
Class car {
Private:
Int seatNum,speed;};
Write a default constructor that sets the data attributes to zeros.
Write the set and get methods.
write a method that increased the speed of the car by 20.
write a method called break that decrease the speed by 10.
write a method that stop the car.
write statements in main function that check the speed of an object, if the speed is >=100 then the speed will be set to the half of the current speed and the final speed should be less than 100.
Q2. Assume Time is a class with three integer data members (hour, minute, and second).
(a) Write the set and get methods of the class. Write also the constructor with parameter.
In main function create an array called ARY of Time variables of length 20 and let a pointer points to the third element in this array.
(b) Write a function that will input the values of hour, minute and second for each element in the array ARY.
© Write the necessary statement(s) that will print the hour, minute, and second of the element at which PTR points.
(d) Write a function that find the minimum time in the array. The minimum time should be printed in the main function.
Q3. Write a student class that has the following attributes:
Class student { Private:
Float avg; Int grade [5];};
write a default constructor that sets the grades array and avg to zeros
write the set method that sets the marks and the avg is the average of the 5 marks.
Write a method that returns the maximum mark in the array grade.
Write an external function to swap the maximum and the minimum mark.
In the main function define a pointer that points to student object and print out the data of the object using its pointer.
In the main function define an array ARR of 10 objects. Write necessary statements to fill this array.
Assume the pointer PTR points to the second element of the array ARR. Use this pointer to print out the data where it is pointed at.
Q4. Write a class of a file contains the following attributes
Size as integer
Ctime (creation time) as time object (in Q2).
1. Create an object of file class. Write an external function to fill this object.
2. Create array of 10 object files. Write a function to fill this array.
3. Write a function to swap the last object with the first object in the array.
4. Write a function that find the size of the last file that was created in the array.
5. Write a function that find the created hour of the smallest file.
*6. Write a function that print out the files information in the array from
the newest to the oldest.
Q5. Write a class rational that has two integers x and y.
Write a method that sets the integers in the simplest form. For example if x=12 and y = 18 (12/18) then the simplest form is 2/ 3.
Write the following methods:
•Addition that adds the rational numbers of two objects.
•Subtraction to subtract the rational numbers of two objects.
•Multiplication that multiply the rational numbers of two objects.
•Division that divide the rational numbers of two objects.
Write a method to find the Least common multiple of a rational number of an object. Example if x=6 and y =9 then the smallest multiple is 18
Write an external function to compare the rational numbers of two objects.
Q6. Assume the class date has the day, month and year attributes. And the class student has id as integer, age as float and admisionDate of type date. And the class course has cid, pointer to date object represent the birthDate and array of 10 students.
Implement the above classes writing all set, get and constructors methods.
Write a method to calculate the average of students ages of course object.
Write external function to compare between two courses. If the average age of the first course is greater than the average age of the second course then print in main function that the course1 is greater than course2 else course2 is greater than course1. (Hint: 1 and 2 in the course represents the course id (cid))
Write a method to find the maximum age of the students in the course.
Write a method to find the minimum age of the student in the course.
In main function create array of 5 courses called ARCOURSE. Write the necessary statements to fill this array.
Write a function to find the position of object in ARCOURSE that has the maximum age.
In main print out the information of course object in the ARCOURSE that has the minimum age.
Write a function to swap the object of maximum age with the object of minimum age.
Write a function that returns a pointer that point to the object of a course in ARCOURSE that has the newest admisionDate.
Note: Automated file (such that: word document, text …etc) Not Acceptable. The assignment should be written by hand


