Connecting Tech Pros Worldwide Help | Site Map

Java Programming

Newbie
 
Join Date: Aug 2009
Posts: 3
#1: Aug 28 '09
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.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Aug 28 '09

re: Java Programming


So what have you done so far?
Newbie
 
Join Date: Aug 2009
Posts: 3
#3: Aug 29 '09

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

classGroceryPrice{

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();

}
}
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Aug 30 '09

re: Java Programming


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

kind regards,

Jos
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#5: Aug 30 '09

re: Java Programming


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
Newbie
 
Join Date: Aug 2009
Posts: 3
#6: Aug 30 '09

re: Java Programming


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