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.
5 3024
So what have you done so far?
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 11,448
Recognized Expert MVP
@OP: I merged your new thread with your previous thread; please don't start new threads on the same topic.
kind regards,
Jos
JosAH 11,448
Recognized Expert MVP
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
Thanks a lot, i will now try your advice this is a very big help for a start.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: inquirydog |
last post by:
Hello-
I, the inquirydog, would like to solicit suggestions for a new
web page I am making:
I am creating a simple website that will translate concepts
between windows os's, Linux, and the...
|
by: Michael N. Christoff |
last post by:
Java, the software developed by Sun Microsystems in the mid-1990s as a
universal operating system for Internet applications, gave NASA a low-cost
and easy-to-use option for running Spirit, the...
|
by: RobertMaas |
last post by:
After many years of using LISP, I'm taking a class in Java and finding
the two roughly comparable in some ways and very different in other
ways. Each has a decent size library of useful utilities...
|
by: Elijah |
last post by:
I have read many of the topics on learning C++ or Java first.
It seems like everyone says something different.
I would like to know if I should learn C++ or Java.
First a little about myself.
I...
|
by: DrUg13 |
last post by:
In java, this seems so easy. You need a new object
Object test = new Object() gives me exactly what I want.
could someone please help me understand the different ways to do the
same thing in...
| |
by: TZESENG |
last post by:
DECEMBER 13, 2005 . Editions: N. America | Europe | Asia | Edition
Preference
News Analysis
By Steve Hamm
Source:
http://www.businessweek.com/technology/content/dec2005/tc20051213_042973.htm...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej...
|
by: r035198x |
last post by:
Inheritance
We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |