You are on page 1of 3

Home Work

1. The equation of a line in standard form is ax+by=c, wherein both a and b cannot be zero,
and a, b, and c are real numbers. If 𝑏 ≠ 0 , then –a/b is the slope of the line. If a=0, then
it is a horizontal line , and if b=0, then it is a vertical line. The slope of a vertical line is
undefined. Two lines are parallel if they have the same slope or both are vertical lines.
Two lines are perpendicular if either one of the lines is horizontal and the other is vertical
or the product of their slopes is –1. Design the class lineType to store a line. To store a
line, you need to store the values of a(coefficient of x), b (coefficient of y), and c. Your
class must contain the following operations:
a. If a line is non vertical, then determine its slope.
b. Determine if two lines are equal. (Two lines a1x+b1y=c1 and a2x+ b2y=c2 are equal
if either a1=a2 , b1=b2, and c1=c2 or a1=ka2 , b1=kb2, and c1=kc2 for some real number
k.)
c. Determine if two lines are parallel.
d. Determine if two lines are perpendicular.
Add write a program to test your class.
2. (Employee Class)Create a class called Employee that includes three pieces of
information as data members—a first name (type string), a last name (type string) and a
monthly salary (type int). Provide a set and a get function for each data member. If the
monthly salary is not positive, set it to 0. Write a test program that demonstrates class
Employee’s capabilities. Create two Employee objects and display each object’s yearly
salary. Then give each Employee a 10 percent raise and display each Employee’s yearly
salary again.

3. Design and implement a class dayType that implements the day of the week in a
program. The class dayType should store the day, such as Sun for Sunday. The program
should be able to perform the following operations on an object of type dayType:
a. Set the day.
b. Print the day.
c. Return the day.
d. Return the next day.
e. Return the previous day.
f. Calculate and return the day by adding certain days to the current day. For
example, if the current day is Monday and we add 4 days, the day to be returned
is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned
is Monday.
g. Add the appropriate constructors.
1
4.
Heart_Rates

+<<property>> Lname:string
+<<property>>Fname:string
+<<property>> YearOfBirth:int

+ Heart_Rates (F:string,L:name,Y:int)
+Maximum_Heart_Rate():int
+Target_Heart_Rate():int
+display():void

- Maximum_Heart_Rate() is calculate with 220 minus the age in years.


- Target_Heart_Rate() is calculate with Maximum_Heart_Rate() divide 220 multiple 100 .
- display() a method to display the age of the persons in years .
- you can use the following to calculate the age in years:
int age =DateTime.Now.Year – (YearOfBirth);

5.
Student

+<<property>>Name:string
+<<property>>Id:string
+degree[]:double

+Student(N:string,Id:string,d[]:double)
+getmaximum():double
+getminimum():double
+getavg():double
+printdegrees():void

2
- getmaximum() : return the maximum degree.
- getminimum () : return the minimum degree.
- getavg() return the average of the degree of the student.
- printdegrees() print all the degrees of the student.

You might also like