Write a class consumerLIC with name(consume name), pno(policy number), pramt(premium amount) and salary as its data members.Find the gross salary of consumer as Premium amount=15%*salary. Gross salary=salary-Premium amount
import
java.util.*;
class consumerLIC
{
public static void main()
{
Scanner Sc=new Scanner(System.in);
System.out.println(“Enter name, policy no.,salary”);
String n=Sc.next();
double pno=Sc.nextDouble();
double salary=Sc.nextDouble();
{
double pramt=0.15*salary;
double gs=salary- pramt;
{System.out.println(“Name: “+n);}
{System.out.println(“Policy number: “+pno); }
{ System.out.println(“Premium amount: “+pramt; }
{System.out.println(“Salary: “+salary);}
{System.out.println(“Gross salary: “+gs);
} } } }
Output: Enter
name, policy no, salary class consumerLIC
{
public static void main()
{
Scanner Sc=new Scanner(System.in);
System.out.println(“Enter name, policy no.,salary”);
String n=Sc.next();
double pno=Sc.nextDouble();
double salary=Sc.nextDouble();
{
double pramt=0.15*salary;
double gs=salary- pramt;
{System.out.println(“Name: “+n);}
{System.out.println(“Policy number: “+pno); }
{ System.out.println(“Premium amount: “+pramt; }
{System.out.println(“Salary: “+salary);}
{System.out.println(“Gross salary: “+gs);
} } } }
Man
764546
50000
Name: Man
Policy number:764546
Premium amount:10000
Salary:50000
Gross salary: 40000
No comments: