Sorry everyone i'm new to java and i have an assingment which i have hand over soon

i just want get an idea how to calculate car insurance premium based on the age,Licence and Engine size
this is my first time come in to this site even so..
if you just give me an hint i will be able to finish the rest my self
thank you very much in advanced
i will be very appreciated your help

here the code that i have so far

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTextPane;
import javax.swing.JTextArea;
import javax.swing.JButton;


public class Testinsurance {

    private JFrame frame;
    private JTextField textField;
    private JTextField textField_1;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Testinsurance window = new Testinsurance();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public Testinsurance() {
        initialize();
    }

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 629, 481);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        JPanel Mainpanel = new JPanel();
        Mainpanel.setBounds(0, 0, 613, 443);
        frame.getContentPane().add(Mainpanel);
        Mainpanel.setLayout(null);

        JLabel lblNewLabel = new JLabel("Please Enter Your Name:");
        lblNewLabel.setBounds(10, 29, 141, 17);
        Mainpanel.add(lblNewLabel);

        textField = new JTextField();
        textField.setBounds(195, 26, 244, 17);
        Mainpanel.add(textField);
        textField.setColumns(10);

        JLabel lblNewLabel_1 = new JLabel("Please Enter Your Age:");
        lblNewLabel_1.setBounds(10, 75, 141, 14);
        Mainpanel.add(lblNewLabel_1);

        textField_1 = new JTextField();
        textField_1.setBounds(195, 72, 86, 17);
        Mainpanel.add(textField_1);
        textField_1.setColumns(10);

        JLabel lblNewLabel_2 = new JLabel("Please Choose Your Gender:");
        lblNewLabel_2.setBounds(10, 129, 141, 17);
        Mainpanel.add(lblNewLabel_2);

        JRadioButton rdbtnNewRadioButton = new JRadioButton("Male");
        rdbtnNewRadioButton.setBounds(193, 126, 109, 23);
        Mainpanel.add(rdbtnNewRadioButton);

        JRadioButton rdbtnNewRadioButton_1 = new JRadioButton("Female");
        rdbtnNewRadioButton_1.setBounds(330, 126, 109, 23);
        Mainpanel.add(rdbtnNewRadioButton_1);

        JLabel lblNewLabel_3 = new JLabel("Your licence type: ");
        lblNewLabel_3.setBounds(10, 186, 141, 17);
        Mainpanel.add(lblNewLabel_3);

        JCheckBox chckbxNewCheckBox = new JCheckBox("Full Irish");
        chckbxNewCheckBox.setBounds(195, 183, 97, 23);
        Mainpanel.add(chckbxNewCheckBox);

        JCheckBox chckbxNewCheckBox_1 = new JCheckBox("Learning Permit");
        chckbxNewCheckBox_1.setBounds(330, 183, 109, 23);
        Mainpanel.add(chckbxNewCheckBox_1);

        JLabel lblNewLabel_4 = new JLabel("Cover Type: ");
        lblNewLabel_4.setBounds(10, 236, 97, 17);
        Mainpanel.add(lblNewLabel_4);

        JComboBox comboBoxCover = new JComboBox();
        comboBoxCover.setBounds(195, 234, 132, 17);
        comboBoxCover.setModel(new DefaultComboBoxModel(new String[] {"Compahensive", "Third Part Fire & Theift", "Thirdpart Only"}));
        Mainpanel.add(comboBoxCover);

        JLabel lblEngine = new JLabel("Your engine size is:");
        lblEngine.setBounds(10, 294, 116, 17);
        Mainpanel.add(lblEngine);

        JComboBox comboBox = new JComboBox();
        comboBox.setBounds(193, 292, 134, 19);
        comboBox.setModel(new DefaultComboBoxModel(new String[] {"1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6"}));
        Mainpanel.add(comboBox);

        JTextArea textArea = new JTextArea();
        textArea.setBounds(172, 338, 276, 94);
        Mainpanel.add(textArea);

        JButton btnGetC = new JButton("Get Quote");
        btnGetC.setBounds(18, 384, 89, 23);
        Mainpanel.add(btnGetC);
    }
}

Recommended Answers

All 6 Replies

how to calculate car insurance premium based on the age,Licence and Engine size

That sounds like you need a formula that takes those values and some constants to compute the premium.

What problems are you having getting the values needed and computing the premium?

I don't next if u could give me so hint about that formula it will be great thanks

Sorry about my poor English I meant I don't know what do next could u give some hint about the formula

I have no idea what formula you need. You need to get that from the person that gave you the assignment.
I'd assume there would be a rate based on ranges of ages: higher for younger drivers, average for middle aged people and then higher for the very old.
Larger engines could be more expensive,
No idea what license would do to the rate.

yeh i know there must be rate in terms of value of the premium

let say if i decide to charge the young drivers around 800 for year and middle age 6500 for year how would i do that sorry as i said i'm new to this and i 'll be appreciate if you could give me an example or hints how is going to will work thanks

On paper, Make a table of the rates based on the ages. For example:
age rate
1-12 400
13-25 600
26-50 300
51-65 350
66-90 500

Then in the program use if statements to select the rate base on the age as set in the table of rates you have decided on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.