Ask Question

Insurance companies suggest that people should insure a building for at least 80 percent of the cost to replace it. Write a program that accepts the cost of a building, sends it to a method which calculates the recommended insurance, and then displays the result in a currency format.

+1
Answers (1)
  1. 29 March, 23:57
    0
    Program 1:

    import java. util.*;

    class Kilo

    {

    public static void main (String[] args)

    {

    Scanner sc = new Scanner (System. in);

    System. out. println ("Enter distance in Kilometers ");

    double Kilometers = sc. nextDouble ();

    double dist = KiloToMeters (Kilometers);

    System. out. println ("The kilometers in miles : "+dist);

    }

    public static double KiloToMeters (double Kilometers)

    {

    double Miles = Kilometers * 0.6214;

    return Miles;

    }

    }

    Program 2:

    import java. text. NumberFormat;

    import java. util.*;

    public class Insurance {

    public static void main (String[] args) {

    System. out. println ("Enter the cost of building:");

    Scanner sc=new Scanner (System. in);

    Double building=sc. nextDouble ();

    double cost = calc (building);

    NumberFormat val = NumberFormat. getCurrencyInstance ();

    System. out. println ("Insurance amount:" + val. format (cost));

    }

    private static double calc (Double building)

    {

    Double insurance_cost;

    insurance_cost = (building*80/100);

    return insurance_cost;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Insurance companies suggest that people should insure a building for at least 80 percent of the cost to replace it. Write a program that ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers