CC 103 - Intermediate Programming
CC 103 - Intermediate Programming
Prefinal Project
class Member {
public Member(String name, int age, String phoneNumber, String address, int
hour_work,double rate_per_hour) {
this.name = name;
this.age = age;
this.phoneNumber = phoneNumber;
this.address = address;
this.hour_work = hour_work;
this.rate_per_hour = rate_per_hour;
}
CC 103 – Intermediate Programming
Prefinal Project
String address, int hour_work, double rate_per_hour, String specialization) {super(name, age,
phoneNumber, address, hour_work, rate_per_hour); this.specialization = specialization;
String address, int hour_work, double rate_per_hour, String department) {super(name, age,
phoneNumber, address, hour_work, rate_per_hour); this.department = department;
manager.printSalary();
2. Create a class named Square that contains data fields for height, width, and surfaceArea,
and a method named computeSurfaceArea (). Create a child class name Cube, which
contains an additional data field named depth, and a computeSurfaceArea () method that
overrides the parent method. Write an application that instantiates a Square object and a
Cube object and display the surface areas of the objects.
import java.util.Scanner;
class Square{
double height;
double width;
double surfaceArea;
this.height = height;
this.width = width;
}
CC 103 – Intermediate Programming
Prefinal Project
double depth;
super(height,width);
this.depth = depth;
double h,w,d;
h = in.nextDouble();
w = in.nextDouble();
CC 103 – Intermediate Programming
Prefinal Project
d = in.nextDouble();
System.out.println("\nSquare");
square.computeSurfaceArea();
System.out.println("\nCube");
cube.computeSurfaceArea();