Write a class MethodReturn which contains instance method displaySalary(double salary, double hra) to calculate the salary of Vishal.

0

Assignment: Module 03- Part 01

Write a class MethodReturn which contains instance method displaySalary(double salary, double hra) to calculate the salary of Vishal.
Assignment: Module 03- Part 01

08. Write a class MethodReturn which contains instance method displaySalary(double salary, double hra) to calculate the salary of Vishal.

Input parameters : 

displaySalary(20000,2000)

Output: 

Vishal salary is 22000.0

class MethodReturn {
    public void displaySalary(double salary, double hra) {
        double vishalSalary = salary + hra;
        System.out.println("Vishal salary is " + vishalSalary);
    }
}

public class Main {
    public static void main(String[] args) {
        MethodReturn obj = new MethodReturn();
        obj.displaySalary(20000, 2000); //output: Vishal salary is 22000.0
    }
}   
This is printed to the console by the 'System.out.println' statement in the 'displaySalary' method. The output is the salary of Vishal calculated by adding his salary and hra.

👉Write a class AscendingArray to sort the array values using control structures👈

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates