Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are to write a program for small insurance company. The program is supposed

ID: 3690079 • Letter: Y

Question

You are to write a program for small insurance company.  The program is supposed to determine the cost of automobile insurance premium for each family member, based on their ages. The basic insurance price is $1,000 per year per person plus an additional amount based on age, per the table below.

Age

Rate

16 to 19

Additional 15% of basic price

20 to 25

Additional 5% of basic price

Over 25

Discount 10% of basic price

Any other age

No insurance

Your program must read name and age from the following file named data.txt.

Data.txt :

Lisa  Smith 21

Jack Smith 56

John Baker 23

Marry Jones 32

Age

Rate

16 to 19

Additional 15% of basic price

20 to 25

Additional 5% of basic price

Over 25

Discount 10% of basic price

Any other age

No insurance

Explanation / Answer

package chegg;

import java.io.File;

import java.util.Scanner;

import java.io.IOException;

public class TextFile

{

public static void main(String[] args) throws IOException

{

   Scanner input = new Scanner(new File("E://data.txt"));

String name[]=new String[8];

int age[]=new int[8];

int price[]=new int[4];

int i=0,j=0;

   while(input.hasNext()&&i<8)

   {

     name[i++] = input.next();

     age[i++] = input.nextInt();

   

   }

     float pr=0.0f;

       pr=(1000/100)*5;

   

       price[j++]=(int) (pr+1000);

       System.out.println("age of the person is "+age[1]+" so basic price will be"+price[0]+" name of the person is "+name[0]);

    

pr=0;

      pr = 10*(1000/100);

price[j++]=(int) (1000-pr);

       System.out.println("age of the person is "+age[3]+" so basic price will be"+price[1]+" name of the person is "+name[2]);

   pr=(1000/100)*5;

   

       price[j++]=(int) (pr+1000);

       System.out.println("age of the person is "+age[5]+" so basic price will be"+price[2]+" name of the person is "+name[4]);

    

      pr = 10*(1000/100);

price[j++]=(int) (1000-pr);

       System.out.println("age of the person is "+age[7]+" so basic price will be"+price[3]+" name of the person is "+name[6]);

}

}

//this is the text file:

LisaSmith    21

JackSmith    56

JohnBaker    23

MarryJones   32

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote