Forums

Help › Forums

I'm in Need of a Programmer's Help!

rated by 0 users
Sun, Feb 10 2013 2:59 AM (4 replies)
  • Buggyyy
    1,963 Posts
    Sat, Feb 9 2013 3:43 PM

    Hello guys. I'm currently enrolled on a college programming class merely focused on Java for this semester. The program we use to write code is called jGRASP. We use it everyday the class meets therefore, it would help to have it at home as well. I have it downloaded on my computer, but it can't run without Java 1.5 or higher as you can see by this screenshot. It also has a small message below explaining something about something I don't understand. I was wondering if anyone could help me with this, for I want to be able to use jGRASP for practicing writing programs and whatnot. Any help would be appreciated.

    P.S. I've already downloaded the Java 1.5 or higher which I believe is the same as the Java Development Kit (JDK). I just can't get it to run because that message box is giving me instructions for something I'm unaware of how to do.

  • andyson
    6,415 Posts
    Sat, Feb 9 2013 4:56 PM

    Google/Yahoo are wonderful things......this might help

    http://answers.yahoo.com/question/index?qid=20121021111136AAsm2Vm

  • Buggyyy
    1,963 Posts
    Sat, Feb 9 2013 5:17 PM

    I found and fixed the problem. I wrote this example program in minutes. Thank god for reading the textbook. :)

     

    // Jonathan Harps

    // February 9, 2013

    // This is a program practicing some basic Programming Fundamentals

     

    public class Pizza

    {

    public static void main(String[] args)

    {

    double cost = 42.59;          // The price of the of the Pizza order without tax.

    double tax = 0.08;               // The amount of tax for the order.

    double total;                        // The total amount of the entire order.

     

    tax = cost * 0.08; // Tax amount based on Texas state regulations

    total = cost + tax;

     

    System.out.println("The cost of the pizza order was " + cost); 

    System.out.println("The amount of tax to be added is " + cost * 0.08);

              System.out.print("The total cost of the entire order is " + total + " which is                           rounded");

              System.out.println(" to about $45.99.");

    }

    }

    If you ran the program after you compiled it, it would look like this:
    The cost of the pizza order was 42.59
    The amount of tax to be added is 3.4072000000000005
    The total cost of the entire order is 45.99720000000001 which is rounded to about $45.99.

     

  • ZioMio
    4,680 Posts
    Sat, Feb 9 2013 11:34 PM

    Yeah but how much a slice! LoL

  • saltiresfan
    2,266 Posts
    Sun, Feb 10 2013 2:59 AM

    Buggyyy:

    I found and fixed the problem. I wrote this example program in minutes. Thank god for reading the textbook. :)

     

    // Jonathan Harps

    // February 9, 2013

    // This is a program practicing some basic Programming Fundamentals

     

    public class Pizza

    {

    public static void main(String[] args)

    {

    double cost = 42.59;          // The price of the of the Pizza order without tax.

    double tax = 0.08;               // The amount of tax for the order.

    double total;                        // The total amount of the entire order.

     

    tax = cost * 0.08 tax; // Tax amount based on Texas state regulations

    total = cost + tax;

     

    System.out.println("The cost of the pizza order was " + cost); 

    System.out.println("The amount of tax to be added is " + cost * 0.08  tax);

              System.out.print("The total cost of the entire order is " + total + " which is                           rounded");

              System.out.println(" to about $45.99.");

    }

    }

    If you ran the program after you compiled it, it would look like this:
    The cost of the pizza order was 42.59
    The amount of tax to be added is 3.4072000000000005
    The total cost of the entire order is 45.99720000000001 which is rounded to about $45.99.

     

    Small correction for you. You've not used the redefined variable for tax. Instead you've calculated it again. Say tax changes; you're then left changing all instances in your code rather than changing the variable.

     

    Always think about coding efficiently. I would probably use this:

    double cost = 42.59;          // The price of the of the Pizza order without tax.

    double tax = 0.08;               // The amount of tax for the order.

    double total = (tax + 1) * cost;     // The total amount of the entire order. (this could also be '(tax*cost) + cost'.

     

     

    tax = cost * 0.08 tax; // Tax amount based on Texas state regulations

    total = cost + tax;

    You should also consider a round down function (for type double not integer for your last line).

    Nice start though :)

RSS