3 Replies Latest reply on May 19, 2014 10:43 PM by ebd09db6-d30a-4e8d-a462-4c946d0de16e

    Java GUI

    ebd09db6-d30a-4e8d-a462-4c946d0de16e

      I took a Java class last semester. We never got to the chapter on GUI's but I'd like to start making them. I just want to add a text field and a label next to it that says "Hourly Wage".

      Also, when I run this in Xcode, it reports back with "Shell Script Invocation Error" "Command usr/bin/java failed with exit code 1".

      Here's my program:

       

      package summerIncome;

      import java.util.Scanner;

       

      public class SummerIncomeCalculator {

      public static void main(String[] args) {

      jFrame frame = new Jframe("Summer Income Calculator");

      frame.setSize(400,300);

      frame.setLocationRelativeTo(null);

      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      frame.setVisible(true);

       

      add(new JTextField("Income in dollars per hour");

       

      Scanner input = new Scanner(System.in);

      System.out.println("Enter hourly wage:");

      double hourly = input.nextDouble();

      //Pre-tax income

      double weekly = hourly * 40;

      double total = weekly * 10;

      System.out.println("Summer earnings before tax are " + total);

      //Tax deductions

      double tax = total * .10;

      double tax2 = tax * .3;

      double tax3 = tax2 * .765;

      double total2 = total - tax3;

      System.out.println("Total Summer earnings after tax are $ "

      + total2);

      input.close();

      }

       

       

      }