Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HELP NEEDED

janpjanp Member Posts: 7
Hi I am new to Java and having lots of problems, I have written some of the code I need but am struggling to put it all together is ther anyone that would be aple to help me?

Comments

  • NelbyNelby Member Posts: 2
    : Hi I am new to Java and having lots of problems, I have written some of the code I need but am struggling to put it all together is ther anyone that would be aple to help me?
    :

    I'd be glad to help in any way i could, but you'll have to be a little more descriptive with your problems
  • janpjanp Member Posts: 7
    : : Hi I am new to Java and having lots of problems, I have written some of the code I need but am struggling to put it all together is ther anyone that would be aple to help me?
    : :
    :
    : I'd be glad to help in any way i could, but you'll have to be a little more descriptive with your problems
    :
    right, I am trying to contruct a program that does quotes for jobs the rules are as follows

    Hours less than 8 25 charge
    Hours less than 40 but larger than 8 22.50
    Hours More than 40 2.1 and for an immediate job start add 10%

    The coding I have already got is as follows
    I am struggling with contructors etc there will be 2 programmes here
    SystemOut.println('Enter material Cost')
    rawmaterialcost = inputread.int ();

    and the same for each input cost, hours and if job starts within month

    if within month = Y or y then totalcost = cost+10%

    if noofhours <=8 then cost = 25* noofhours and etc.

    I badsically need help on the contructors and the frilly bits (i think)
    thanks

  • RobF11RobF11 Member Posts: 6
    : : : Hi I am new to Java and having lots of problems, I have written some of the code I need but am struggling to put it all together is ther anyone that would be aple to help me?
    : : :
    : :
    : : I'd be glad to help in any way i could, but you'll have to be a little more descriptive with your problems
    : :
    : right, I am trying to contruct a program that does quotes for jobs the rules are as follows
    :
    : Hours less than 8 25 charge
    : Hours less than 40 but larger than 8 22.50
    : Hours More than 40 2.1 and for an immediate job start add 10%
    :
    : The coding I have already got is as follows
    : I am struggling with contructors etc there will be 2 programmes here
    : SystemOut.println('Enter material Cost')
    : rawmaterialcost = inputread.int ();
    :
    : and the same for each input cost, hours and if job starts within month
    :
    : if within month = Y or y then totalcost = cost+10%
    :
    : if noofhours <=8 then cost = 25* noofhours and etc.
    :
    : I badsically need help on the contructors and the frilly bits (i think)
    : thanks
    :
    :

    I'm not doing this in a compiler, so somethings may be slightly off, also there might be extra n's b/c my n key sticks.

    import javax.swing.*;

    public class JobQuotes extends JFrame implements ActionListener{
    int numHours, rawMaterials;
    double total;
    boolean withinMonth;
    JTextArea monthInput, numHoursInput, rawMaterialsInput;
    JButton submit;

    public static void main(String args[]){
    JFrame frame = new JFrame("Input Information");
    Container c=frame.getContentPane();
    c.setLayout(new GridLayout(1,1));
    JobQuotes one = new JobQuotes(frame);
    c.add(one);
    frame.pack();
    frame.setVisible();
    }

    public JobQuotes(JFrame frame){
    this.frame = frame;
    monthInput = new JTextField(10);
    rawMaterialsInput = new JTextField(10);
    numHoursInput = new JTextField(10);
    submit = new JButton("Submit");
    submit.addActionListener(this);
    JPanel upper = new JPanel();
    upper.setLayout(new BorderLayout());
    upper.add("Cost Of Raw Materials", BorderLayout.WEST);
    upper.add(rawMaterialsInput, BorderLayout.CENTER);
    JPanel middle = new JPanel();
    middle.setLayout(new BorderLayout());
    middle.add("Number of Hours", BorderLayout.WEST);
    middle.add(numHoursInput, BorderLayout.CENTER);
    JPanel lower = new JPanel();
    lower.setLayout(new BorderLayout());
    lower.add("Within Month (y or n)", BorderLayout.WEST);
    lower.add(monthInput, BorderLayout.CENTER);
    lower.add(submit, BorderLayout.EAST);
    JPanel all = new JPanel();
    all.setLayout(new BorderLayout());
    all.add(upper, BorderLayout.NORTH);
    all.add(middle, BorderLayout.CENTER);
    all.add(lower, BorderLayout.SOUTH);

    }

    public void actionPerformed(ActionEvent e) {
    numHours=Integer.parseInt(numHoursInput.getText());
    rawMaterials = Integer.parseInt(rawMaterialsInput.getText());
    if(month.getText().equalsIgnoreCase("y"));
    withinMonth=true;
    else
    withinMonth = false;
    if(numHours<=8){
    if(withinMonth==true)
    total = (rawMaterials+numHours*25)*1.1;
    else
    total = rawMaterial+numHours*25;
    }
    else if(numHours>8 && numHours<=40){
    if(withinMonnth==true)
    total = (rawMaterials+numHours*22.5)*1.1;
    else
    total = rawMaterials+numHours*22.5;
    }
    else{
    if(withinMonnth==true)
    total = (rawMaterials+numHours*21.1)*1.1;
    else
    total = rawMaterials+numHours*21.1;
    }
    JOptionPane.showMessageDialog(null, "The Job Quote is $" + total);
    System.out.println(The Job Quote is $"+total);
    }
    }



  • janpjanp Member Posts: 7
    : : : : Hi I am new to Java and having lots of problems, I have written some of the code I need but am struggling to put it all together is ther anyone that would be aple to help me?
    : : : :
    : : :
    : : : I'd be glad to help in any way i could, but you'll have to be a little more descriptive with your problems
    : : :
    : : right, I am trying to contruct a program that does quotes for jobs the rules are as follows
    : :
    : : Hours less than 8 25 charge
    : : Hours less than 40 but larger than 8 22.50
    : : Hours More than 40 2.1 and for an immediate job start add 10%
    : :
    : : The coding I have already got is as follows
    : : I am struggling with contructors etc there will be 2 programmes here
    : : SystemOut.println('Enter material Cost')
    : : rawmaterialcost = inputread.int ();
    : :
    : : and the same for each input cost, hours and if job starts within month
    : :
    : : if within month = Y or y then totalcost = cost+10%
    : :
    : : if noofhours <=8 then cost = 25* noofhours and etc.
    : :
    : : I badsically need help on the contructors and the frilly bits (i think)
    : : thanks
    : :
    : :
    :
    : I'm not doing this in a compiler, so somethings may be slightly off, also there might be extra n's b/c my n key sticks.
    :
    : import javax.swing.*;
    :
    : public class JobQuotes extends JFrame implements ActionListener{
    : int numHours, rawMaterials;
    : double total;
    : boolean withinMonth;
    : JTextArea monthInput, numHoursInput, rawMaterialsInput;
    : JButton submit;
    :
    : public static void main(String args[]){
    : JFrame frame = new JFrame("Input Information");
    : Container c=frame.getContentPane();
    : c.setLayout(new GridLayout(1,1));
    : JobQuotes one = new JobQuotes(frame);
    : c.add(one);
    : frame.pack();
    : frame.setVisible();
    : }
    :
    : public JobQuotes(JFrame frame){
    : this.frame = frame;
    : monthInput = new JTextField(10);
    : rawMaterialsInput = new JTextField(10);
    : numHoursInput = new JTextField(10);
    : submit = new JButton("Submit");
    : submit.addActionListener(this);
    : JPanel upper = new JPanel();
    : upper.setLayout(new BorderLayout());
    : upper.add("Cost Of Raw Materials", BorderLayout.WEST);
    : upper.add(rawMaterialsInput, BorderLayout.CENTER);
    : JPanel middle = new JPanel();
    : middle.setLayout(new BorderLayout());
    : middle.add("Number of Hours", BorderLayout.WEST);
    : middle.add(numHoursInput, BorderLayout.CENTER);
    : JPanel lower = new JPanel();
    : lower.setLayout(new BorderLayout());
    : lower.add("Within Month (y or n)", BorderLayout.WEST);
    : lower.add(monthInput, BorderLayout.CENTER);
    : lower.add(submit, BorderLayout.EAST);
    : JPanel all = new JPanel();
    : all.setLayout(new BorderLayout());
    : all.add(upper, BorderLayout.NORTH);
    : all.add(middle, BorderLayout.CENTER);
    : all.add(lower, BorderLayout.SOUTH);
    :
    : }
    :
    : public void actionPerformed(ActionEvent e) {
    : numHours=Integer.parseInt(numHoursInput.getText());
    : rawMaterials = Integer.parseInt(rawMaterialsInput.getText());
    : if(month.getText().equalsIgnoreCase("y"));
    : withinMonth=true;
    : else
    : withinMonth = false;
    : if(numHours<=8){
    : if(withinMonth==true)
    : total = (rawMaterials+numHours*25)*1.1;
    : else
    : total = rawMaterial+numHours*25;
    : }
    : else if(numHours>8 && numHours<=40){
    : if(withinMonnth==true)
    : total = (rawMaterials+numHours*22.5)*1.1;
    : else
    : total = rawMaterials+numHours*22.5;
    : }
    : else{
    : if(withinMonnth==true)
    : total = (rawMaterials+numHours*21.1)*1.1;
    : else
    : total = rawMaterials+numHours*21.1;
    : }
    : JOptionPane.showMessageDialog(null, "The Job Quote is $" + total);
    : System.out.println(The Job Quote is $"+total);
    : }
    : }
    :
    : THANKS, I WILL TRY THAT
    :
    :

Sign In or Register to comment.