write the program by using either inputstreamreader or scanner classes
Attachments:
Answers
Answered by
6
This program is by scanner class. I don't think the Input Stream will be there in exams for boards.
import java.util.*;
class Insurance
{
public static void main()
{
Scanner in=new Scanner(System.in);
double sum,pre,dis=0.0,comm=0.0;
String name;
System.out.println("Enter name of policy holder");
name=in. nextLine();
System.out.println("Enter sum assured");
sum=in.nextDouble();
System.out.println("Enter first premium");
pre=in.nextDouble();
if(sum<=100000)
{
dis=5.0/100*pre;
comm=2.0/100*sum;
}
else if(sum>100000&∑<=200000)
{
dis=8.0/100*pre;
comm=3.0/100*sum;
}
else if(sum>200000&∑<=500000)
{
dis=10.0/100*pre;
comm=5.0/100*sum;
}
else
{
dis=15.0/100*pre;
comm=7.5/100*sum;
}
System.out.println("Name of policy holder:"+name);
System.out.println("Premium:"+pre);
System.out.println("Sum assured:"+sum);
System.out.println("Discount:"+dis);
System.out.println("Commission:"+comm);
}
}
Please give me at least a thank you. It's a lot of hard work to type a computer program in a mobile.
import java.util.*;
class Insurance
{
public static void main()
{
Scanner in=new Scanner(System.in);
double sum,pre,dis=0.0,comm=0.0;
String name;
System.out.println("Enter name of policy holder");
name=in. nextLine();
System.out.println("Enter sum assured");
sum=in.nextDouble();
System.out.println("Enter first premium");
pre=in.nextDouble();
if(sum<=100000)
{
dis=5.0/100*pre;
comm=2.0/100*sum;
}
else if(sum>100000&∑<=200000)
{
dis=8.0/100*pre;
comm=3.0/100*sum;
}
else if(sum>200000&∑<=500000)
{
dis=10.0/100*pre;
comm=5.0/100*sum;
}
else
{
dis=15.0/100*pre;
comm=7.5/100*sum;
}
System.out.println("Name of policy holder:"+name);
System.out.println("Premium:"+pre);
System.out.println("Sum assured:"+sum);
System.out.println("Discount:"+dis);
System.out.println("Commission:"+comm);
}
}
Please give me at least a thank you. It's a lot of hard work to type a computer program in a mobile.
ICSEgirl:
in the third line of the program y didnt u write string args[]??
Similar questions