please tell this answer class 9 icse
Attachments:
Answers
Answered by
1
Answer:
This is the required program for the question. It is written in Java.
import java.util.*;
public class Java {
public static void main(String[] args) {
double b, d, g;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the basic salary: ");
b=sc.nextDouble();
if(b<0) {
System.out.println("Invalid Input.");
}
else {
if(b<=10000)
d=15.0/100.0*b;
else if(b<=20000)
d=20.0/100.0*b;
else if(b<=30000)
d=25.0/100.0*b;
else
d=30.0/100.0*b;
g=b+d;
System.out.println("Basic Salary\t\tDA\t\tGross Salary");
System.out.println(b+"\t\t\t\t\t"+d+"\t\t"+g);
}
sc.close();
}
}
Steps to Solve:
- Ask the user to enter the basic.
- Check if the basic is valid or not.
- If valid, calculate DA as per the conditions given and display the Gross, Basic and DA accordingly.
See the attachment for output ☑.
Attachments:
Similar questions