Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Java coding, solution needed

  1. #1
    Junior Member
    Join Date
    Sep 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java coding, solution needed

    Implement a class Calculator with the method mentioned below.


    Method Description
    findAverage()
    Calculate the average of three numbers
    Return the average rounded off to two decimal digits
    Test the functionalities using the provided Tester class.

    Code:

    class Calculator {

    // Implement your code here
    }

    class Tester {

    public static void main(String args[]) {
    Calculator calculator = new Calculator();
    // Invoke the method findAverage of the Calculator class and display the average
    }
    }

  2. #2
    Junior Member
    Join Date
    Sep 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java coding, solution needed

    Implement the class Teacher based on the class diagram and description given below.

    Method Description
    Teacher(String teacherName, String subject, double salary)
    Initialize the values of all the instance variables appropriately with the values passed
    Create a Tester class. Create 4 objects of Teacher class. Create an array of type Teacher store the created objects and display the details of the teachers.


    class Teacher {
    //Implement your code here
    }

    class Tester {
    public static void main(String[] args) {
    // Implement your code here
    }
    }

  3. #3
    Junior Member
    Join Date
    Sep 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java coding, solution needed

    Consider the class Employee given below for representing employees of an organization. It has 5 different instance variables and a method to calculate the total salary based on the jobLevel.

    Salary is calculated in the calculateSalary() method.

    Make necessary changes to the class by making all the attributes private and by adding necessary accessor and mutator methods thus bringing in Encapsulation.

    class Employee {

    String employeeId;
    String employeeName;
    int salary;
    int bonus;
    int jobLevel;

    public void calculateSalary() {
    if (this.jobLevel >= 4) {
    this.bonus = 100;
    } else {
    this.bonus = 50;
    }
    this.salary += this.bonus;
    }
    }

    class Tester {

    public static void main(String args[]) {

    Employee employee = new Employee();
    employee.employeeId = "C101";
    employee.employeeName = "Steve";
    employee.salary = 650;
    employee.jobLevel = 4;

    employee.calculateSalary();

    System.out.println("Employee Details");
    System.out.println("Employee Id: " + employee.employeeId);
    System.out.println("Employee Name: " + employee.employeeName);
    System.out.println("Salary: " + employee.salary);

    }
    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,363
    Thanks
    54
    Thanked 2,636 Times in 2,586 Posts

    Default Re: Java coding, solution needed

    What have you tried? Post your code with any questions you have.

    Be sure to wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    Note: If no effort is shown on this thread, it will be moved to the junk heap.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: June 4th, 2021, 06:36 PM
  2. Easy calculate coding needed.
    By mic2bless in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 2nd, 2012, 06:18 AM
  3. Replies: 2
    Last Post: February 19th, 2012, 07:36 AM
  4. Help needed with java coding!!
    By Bentino in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 14th, 2012, 08:09 PM

Tags for this Thread