Answer to Question #230206 in Java | JSP | JSF for Cypher

Question #230206
a. JAVA is known to be an object oriented program. Objects are also
known to exist in real life. You have been invited as a computer science
student to distinguish between real life objects and object found in object
oriented program OOP

b. Write an OOP to compare the risk factor that will lead to high payment of
life insurance premium. The variables to consider are: age, weight, and
height.

I) The program should request for the variables to be inputted from the keyboard.

II) Premium should be high if age is greater than or equal to 60 years and
weight is greater than or equal 80kg and has greater than or equal 6.8
feet. Otherwise, the premium should be low

III) Critically explain how the program could be adopted by allied
companies for their operations.
1
Expert's answer
2021-08-27T13:48:40-0400

a) Objects in real life are tangible and can be grabbed. For example, a laptop is real world object since it can be touched and used to perform a particular task like developing applications. Real life objects are simply physical things. On the other hand, in object oriented, the objects found are the instances of various classes. For example, a class Car, can have wheel as an instance. Therefore, object in Object Oriented Programming is a part of class.

b)



package compareriskfactor;


import java.util.Scanner;
public class CompareRiskFactor {
    private int age;
    private float height;
    private float weight;
    CompareRiskFactor(int a, float w, float h){
        age = a;
        height = h;
        weight = w;
    }
    void premium(){
        if((age>=60) && (weight>=80) && (height>=6.8)){
            System.out.println("Premium is high");
        }
        else{
            System.out.println("Premium is low");
        }
            
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter age ");
        int age = input.nextInt();
        System.out.println("Enter weight ");
        float weight = input.nextFloat();
        System.out.println("Enter height ");
        float height = input.nextFloat();
        CompareRiskFactor factor = new CompareRiskFactor(age,weight,height);
        factor.premium();
        
    }
    
}


This program can be adopted by running it on computer; a console or GUI can be used. 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS