Java Programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JavaMas
    New Member
    • Aug 2009
    • 3

    Java Programming

    I am a beginner in Java programming after a few lessions I was provided with this task and I have no clue how to go about it.this appears to be simple but for me is a mountain, if any one could help I will really appreciate it. Here goes the question.

    Design and implement a program in Java that allows a user to enter into an array the price of a number of grocery products in Euro. The program should then copy this array into another array but convert the price of each product from Euro to pounds sterling. The user should be asked how many items they wish to purchase and the arrays sized accordingly. The program should allow the to enter the exchange rate of Euro to pounds and should when it terminates, display the contents of the both arrays and the total cost of the order in both currencies.
    N/B you must make use of method in your program to carry out these tasks.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    So what have you done so far?

    Comment

    • JavaMas
      New Member
      • Aug 2009
      • 3

      #3
      Java programming

      Base on this question:- Design and implement a program that allows the user to enter into an array the price of a number of grocery products in Euro. The program should then copy this array into another array but convert the price of each product from Euro to pounds sterling. The user should be asked how many items they wish to purchase and the arrays sized accordingly. The program should allow The user to enter the exchange rate of Euro to pounds and should when it terminates, display the contents of the both arrays and the total cost of the order in both currencies.
      N/B you must make use of method in your program to carry out these tasks

      , This is what I have done so far and i believe i don't know what i am doing, just need a help, any instruction on how to even start will be of great help.

      classGroceryPri ce{

      public static void main(string[] args){



      double price;
      double euro;
      double pounds;
      double rate = .87;
      int item;
      double array1[]= {2.56,3.31,4.06 ,5.75,8.22,9.01 };

      double array2[] = new double[6];

      System.out.prin tln("Please enter grocery price in euro");

      euro = EasyIn.getDoubl e();


      System.out.prin tln("please enter rate");
      rate = EasyIn.getDoubl e

      pounds = euro * rate;

      System.out.prin tln(euro + " euros is equal to " + pounds+" Pounds ");

      System.out.prin tln("array1");

      for (int i=0; i<array1.length ; i++)
      {
      System.out.prin t(" "+array1[i]);
      }

      System.out.prin tln("\narray2:" );

      for(int j=0; j<array1.length ; j++){
      array2[j] = array1[j];
      System.out.prin tnl(" "+ array2[j]);
      }

      System.out.prin tln("Please enter the number of items you wish to purchase");

      item = EasyIn.getInt() ;

      }
      }

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        @OP: I merged your new thread with your previous thread; please don't start new threads on the same topic.

        kind regards,

        Jos

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          You don't implement what the assignment text asks for: you have a (fixed size) list of groceries and the user should be able to type in the price for a (unit of) grocery (measured in Euros).

          So at the next step you end up with a list of groceries and their price in Euros. The user should be able to type in the amount (measured in units of groceries) s/he wants to buy. You should store those amounts in another array or list.

          Next you should convert the first list to a list of groceries with prices measured in Pounds. The user should set the exchange rate.

          You end up with three arrays or lists: groceries in Euros, groceries in Pounds and the amounts ordered by the user.

          Finally you should print out the totals measured in Euros and Pounds.

          kind regards,

          Jos

          Comment

          • JavaMas
            New Member
            • Aug 2009
            • 3

            #6
            Thanks a lot, i will now try your advice this is a very big help for a start.

            Comment

            Working...