You work in finance at IT company,
The program you are given takes the total income and the tax percent as input, and creates an income object with public total income, tax percent and private net revenue attributes.
Complete the class by methods which will calculate and return the net revenue, so that the given output works correctly.
Sample Input
150000
14
Sample Output
Net revenue: 129000
Hint
To calculate the net revenue from n total income with m tax percent, use n-n*m/100 formula.
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int totalIncome = read.nextInt();
int taxPercent = read.nextInt();
//creating an Income object
Income income = new Income();
income.totalIncome = totalIncome;
income.taxPercent = taxPercent;
income.CalculateNetRevenue();
System.out.println("Net revenue: " + income.getNetRevenue());
}
}
class Income{
public int totalIncome;
public int taxPercent;
//the net revenue is private
private int netRevenue;
//complete setter method
public void CalculateNetRevenue(){
this.netRevenue = totalIncome - totalIncome*taxPercent/100;
//System.out.println(netRevenue);
}
//complete getter method
public int getNetRevenue(){
return netRevenue;
}
}