Create a class called Programmer that includes three pieces of information as instance variables – full name (type String), salary (type double) and age (type int). Your class should have a constructor that initializes the three instance variables. Provide a method named printProgrammerDetails that displays programmer's full name, salary and age. Write a test application named ProgrammerTest that demonstrates class Programmers’s capabilities
class Programmer {
private String fullName;
private double salary;
private int age;
public Programmer() {
}
public Programmer(String fullName, double salary, int age) {
this.fullName = fullName;
this.salary = salary;
this.age = age;
}
public void printProgrammerDetails () {
System.out.println("Full name: "+fullName);
System.out.println("Salary: "+salary);
System.out.println("Age: "+age);
}
}
public class ProgrammerTest {
/**
* The start point of the program
*
* @param args
*
*/
public static void main(String[] args) {
Programmer programmer=new Programmer("Peter Smith", 5255, 35);
programmer.printProgrammerDetails();
}
}
Comments
Leave a comment