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 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.

class GroceryPrice{

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.println("Please enter grocery price in euro");

euro = EasyIn.getDouble();


System.out.println("please enter rate");
rate = EasyIn.getDouble

pounds = euro * rate;

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

System.out.println("array1");

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

System.out.println("\narray2:");

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

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

item = EasyIn.getInt();

}
}

I don't know what EasyIn refers to, but I assume it is this?

http://mindprod.com/jgloss/easyin.html

Let's look at the spec:

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

One, I see no methods in your code other than main, so the way I interpret this line, that's a problem:

N/B you must make use of method in your program to carry out these tasks

So you need to create some functions in your program to handle the separate tasks, presumably including something similar to this:

static double EuroToPounds (double numEuro, double numEuroInPound)
{
    double numPounds = /* equation here */
    return numPounds;
}
Design and implement a program that allows the user to enter into an array the price of a number of grocery products in Euro.

You have your array hard-coded. You need to instead have the user enter each amount in Euros.

double array1[]= {2.56,3.31,4.06,5.75,8.22,9.01};

double array2[] = new double[6];

Pick more descriptive names for your array, like priceInPounds[] and priceInEuros[]

Thanks a lot like i said i am just learning hope to be perfect some day.

This article has been dead for over six months. Start a new discussion instead.