-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUseCourse.java
More file actions
82 lines (82 loc) · 1.66 KB
/
UseCourse.java
File metadata and controls
82 lines (82 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import java.util.*;
class CollegeCourse
{
double Ch = 120.00;
String dpt;
int num;
int c;
double cf;
CollegeCourse(String d, int n, int nc)
{
dpt = d.toUpperCase();
num = n;
c = nc;
cf = Ch * c;
}
String getdpt()
{
return dpt;
}
int getcourseNo()
{
return num;
}
int getCredits()
{
return c;
}
double getcourseFee()
{
return cf;
}
void display()
{
System.out.println("department " + this.getdpt());
System.out.println("Course number " + this.getcourseNo());
System.out.println("Credit hours " + this.getCredits());
System.out.println("Course fee " + this.getcourseFee());
}
}
class LabCourse extends CollegeCourse
{
double lf = 50.00;
double cf;
LabCourse(String dpt, int cn, int c)
{
super(dpt, cn, c);
cf = super.getcourseFee() + lf;
}
double getLabCourseFee()
{
return cf;
}
void display()
{
System.out.println("department " + super.getdpt());
System.out.println("Course number " + super.getcourseNo());
System.out.println("Credit hours " + super.getCredits());
System.out.println("Course fee " + this.getLabCourseFee());
}
}
public class UseCourse{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the department of the course: ");
String dept = sc.nextLine();
System.out.print("Enter the number of the courses ");
int number = sc.nextInt();
System.out.print("Enter the credit hours of the courses ");
int hours = sc.nextInt();
if(dept.equals("BIO") || dept.equals("CHM")|| dept.equals("CIS") || dept.equals("PHY"))
{
LabCourse l = new LabCourse(dept, number, hours);
l.display();
}
else
{
CollegeCourse c = new CollegeCourse(dept, number, hours);
c.display();
}
}
}