Need Help for Java Homework Assignment, Can someone Please help me ?
This is the program that I am supposed to write, and I am terrible confused, as it takes at least 3 different files.
Write a class named GroceryList that representss a person's list of items to buy from the market, and another class named GroceryItemOrder that represents a request to purchase a particular item in a given quantity. (I.E. four boxes of cookies).
**The GroceryList class should use an array field to store the grocery items, as well as keeping track of its size (number of items in the list so far). Assume that a grocery list will have no more than 10 items. A GrocerList object should have the following methods:
public GroceryList()
Constructs a new empty grocery list.
public void add(GroceryItemOrder item)
Adds the given item order to this list, if the list is not full (i.e., has fewer than 10 items).
public double getTotalCost()
Returns the total sum of all grocery item orders in this list.
The GroceryItemOrder class should store an item quantity and a price per unit. A GroceryItemOrder object should have the following methods:
public GrocerItemOrder(String name, int quantity, double pricePerUnit)
Constructs an item order to purchase the item with the given name, in the given quantity, which costs the given pricer per unit.
public double getCost()
Returns the total cost of this item in its given quantity. I.E. 4 boxes of cookies that cost 2.30 per unit, have a total cost of 9.20.
public void setQuantity(int quantity)
Sets the grocery item's quantity to be the given value.
Any suggestions would be sincerely appreciated.
Thanks.
Pete,
I having difficulty with the main class, and getting console to store a users input into a string array ... I will post the code that I have so far. Sorry I am trying real hard to learn ... and just having a frustrating time.
This is what I have in the main file.
import java.util.*;
public class Chapter_8 {
public static void main(String []args){
Scanner console = new Scanner(System.in);
System.out.println("Please enter the first item of your list");
String[]GroceryList = console.next();
System.out.println("Please enter the next item of your list");
String[]GroceryList = console.next();
System.out.println("How many would you like to buy?");
int quantity = consolenextInt();
}This is what I have in the GroceryItem Class file:
public class GroceryList{
public GroceryList(){
Static String []GroceryList ={"beans", "macaroni", "milk", "cheese", "bread", "eggs","hamburger","Hotdogs","peas","cookies"};
for(int i=0;i<5;i++){
System.out.println(GroceryList);
And the final file that I have is the GroceryItemOrder Class file:public GroceryItemOrder(String name, int quantity, double pricePerUnit){
this.name = name;
this.quantity = quantity;
this.pricePerUnit = pricePerUnit;
public double getCost(){
public void setQuantity(int quantity){
Sorry, I know it isn't much, that's why I am frustrated.
Thanks.
Similar Messages
-
I need to change my bluetooth name can someone please help as i`m new to i-phone
Please can someone help me ? i`m new to i-phones an i need to change my bluetooth name, thanks in advance
not sure because like i say i`m new to i-phone an it was boxed an sealed brand new it just kept asking me to do this that an the other lol (mind blowing ) to be honest an i was exited too
-
Got this question on my Java test. Can someone please clarify for me?
You can create concrete object from:
A) An abstract class
B) An Interface
C) Both A & B
D) None of Above
I said interface because I know that we can create an object of interface. But that word 'CONCRETE'??samguan wrote:
You can create concrete object from:
A) An abstract class
B) An Interface
C) Both A & B
D) None of Above
I said interface because I know that we can create an object of interface. It depends on how you interpret the question. I'd say it's poorly worded. But, assuming it's not a trick question, the answer is D. And if you can "create a concrete object from" an interface, then you can also "create a concrete object from" an abstract class. -
I've tried to download the flash player several different times and each time i get a connection error message.It downloads fine and when i run the file to start install, it installs up to 5% and then i get the connection error message. I've tried disabling my antivirus software, closing my browser for install and nothing.Can someone please help me? I'm using Firefox.
Hi!
I had the exact same issue, being on a mac. If you are on a mac and the connection error message occurs, then use this link http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_osx.dmg
It allows you to download it offline, which is what I used.
Hope I was help!
-Haroon -
After Installing the OS x Mountain Lion some o the softwares are asking for Java SE 6 Runtime. Can someone please help me find a solution.
By default, ML no longer comes with the Java runtime preinstalled. I believe the route to enabling Java if you are going to need it is to run the Java Preferences app found in Utilities. It will inform you of Java's absence and offer to install the latest version and activate it. On subsequent runs, the Preferences app will allow you to fine tune how the runtime operates.
Note that the new default operation is for the applet plugin to be disabled. You need to enable it as needed and it self-deactivates if unused in awhile. Also important to note that Java comes in both 32 and 64 bit versions and you can set the preferred order. Default is 64-bit but I've had issues with some applets failing to run and have had to switch the order. -
Can someone please explain and help me? I am unlocking an iphone4 from at&t to use it on the straight talk network. They've confirmed my request to do this and I am now a little confused as to what to do next. They want me to back up the phone using itunes on either a MAC or PC. I do not have an aplle computer but I do have an acer. Sooo, can I use it to do this? Or do I even have to do this to unlock and switch the iphone4 over to a new network? If I do have to what can I do to do this because like I said I do not have a computer by apple? Can anybody walk me through what I need to do next please? I've been waiting to do this for a very long time and I now have the option to have an iphone and use it. Thanks to my awesome boyfriend who Gave me his old iphone when he swapped back to an android. Hahahaha! Please anybody!? Because I sooo don't know what I'm doing and really do not want to mess the phone Or the process up. Thanks to any and all who read this and help me! It is greatly appreciate it!
Install iTunes on your Acer and you can back up the iPhone. Or back it up to iCloud. If you do not back it up you can get it unlocked, but you will lose all of your content.
You can get iTunes from http://www.apple.com/itunes.
Even after unlocking I'm not sure it will work on Straight Talk, because last time I checked ST used Verizon as its carrier, and an AT&T iPhone 4 is not compatible with Verizon's network. You can probably use it on Net 10 or T-Mobile once it is unlocked. -
Hi,
My iphone 4 won't connect to my mac book, it says that I need to install to latest version of itunes 11.1. When I go to itunes and try to update, it says that I have the latest version (10.6.3). Can someone please help me!
thanksYou are probably running OS 10.4 or 10.5 on a PPC Mac. No version of iTunes higher than 10.6.3 is available for these older Macs. I have the same problem, and while I can still use the PPC to sync my iPod, it can't be used to sync an iPhone 4 or higher. The only solution, as I discovered after upgrading to the iPhone 4, is to buy a newer Mac. I was able to get a 2006 MacBook running Lion for under $300, and that has been a lifesaver.
-
Can someone please help a friend of mine get a permanent registration key (not a trial key that expires in 30 days) to replace his lost registration key for Adobe Photoshop CS2? His previous hard drive crashed and he no longer has his registration key. This is vital for his wedding business.
Thanks to everyone for the tips on my CS2 question. It turns out in the end it was some plug-in filter software that was causing the glitch, not a lack of an Adobe registration key. As for why he still uses CS2, it does the job for him, so that's all he needs.
-
HI THERE,
CAN SOMEONE PLEASE HELP ME? I HAVE BEEN TRYING TO RESTORE MY IPHONE4 FROM IOS 4.3.3 TO 5.1.1 FOR THE LAST 6 HOURS AND EVERYTHING GOES THROUGH OK UNTIL IT GETS TO THE RESTORING IPHONE SOFTWARE, IT LOADS 1/2 THEN FREEZES. IVE LEFT IT LIKE THAT FOR AT 30MINS AND NOTHING HAPPENS. IVE TAKEN THE CORD OUT AND HAD TO TURN PHONE OFF AND RESTART, THEN LOAD IT BACK UP TO ITUNES ALL OVER AGAIN. MANY TIMES!!!!! IVE CHANGED CORD AND USB STILL NOTHING? IVE GOTTEN TO THE POINT WHERE I MAY HAVE RUINED IT ALTOGETHER AND NEED TO BUY A NEW PHONE? PLEASE I HOPE SOMEONE OUT THERE CAN HELP?:
MANY THANKSYou may not get a response as you are shouting at everyone.
All caps indicates shouting, is considered rude, and is difficult to read.
Many will not read such posts.
Try turning off you caps lock and asking again. -
Recently I installed iTunes on my computer so that I could put music on my new iPad and it was fine, the next day when I went to put some more on it it asked me to download the newest version of iTunes and I did but since then I have been having trouble getting access to iTunes. I have uninstalled and reinstalled the latest itunes version and it still says that I need to reinstall it. Can someone please help me
Hi l.johnson66,
If you are having issues with iTunes after an attempted update, you may find the following article helpful:
iTunes 11.1.4 for Windows: Unable to install or open
http://support.apple.com/kb/TS5376
Regards,
- Brenden -
Can someone please help i cant connect to itunes from my iphone 4 ,,i had an iphone 3 and when i got my iphone 4 i changed my email address for new itunes account and my old phone which hubby uses is changed aswell ..for some reason i cant update my apps off m iphone & in itunes via pc it will say apps are all up to date but i have 25 apps that need updating please can someone help ,, i can download a new app but i cant update existing ones ,,,
very frustrated iphone user !!Changing devices is no reason to create a new Apple ID.
All content purchased from iTunes is permanently linked to the Apple ID it was purchased with.
To update apps purchased with the old ID, you MUST sign in with that Apple ID. -
Just bought a new Ipod Nano, 6th generation, was tryin to following directions on syncing, when I plug it in too my computer,
it doesnt give me any directions on syncing or connecting to my computer, can someone please help me??There should be an option (on the left hand side of your iTunes) for your iPod. Then when you click on it you will just need to setup and there will be an option to sync at the bottom right hand corner
-
Whenever i try to install or update my mac to OS X Yosemite it asks for my apple ID and then takes me on to a page to fill in a credit card information form. However i don't like to share information like that online can someone please help me ?
Not really, but you did need that when you got your Apple ID.
Creating an iTunes Store, App Store, iBooks Store, and Mac App Store account without a credit card -
When I go to my iTunes Store and download something, for some reason it's not letting me download app it's saying there's a billing issue, when I correct it, it's says contact iTunes/ support can someone please help me, I really want too listen to paying
You need to do as provided - contact iTunes Store support.
http://www.apple.com/emea/support/itunes/contact.html -
Can someone please help? Recently just had my iPhone 4S reconnected. I've now waited the 24 hours that you need to wait till everything goes back to normal. However on a phone call I can hear whoever I'm calling but they can't hear me?
i had the same problem a few weeks ago and i had only had my 3g iphone for a few weeks. It was as if i was on permanent mute. I could hear others fine, but they couldn't hear me, even if i used speakerphone or even a bluetooth.
i took it to an apple store and they did a real quick test (they first did a system restore, then they took my phone and tried calling another employee). Once they validated it wasn't working, they replaced my phone quickly with no questions asked. Just make sure to back up everything on I-Tunes before you go in so that you dont lose any info. might want to do the restore before you go in, as well, otherwise you'll have to wait for them to do it at the store, which takes them 15 mins or so.
Hope this helps.
Maybe you are looking for
-
Problem with S001 - Key field Sequence in table
Hi, We want to use the extractor 2LIS_01_S001 with Delta. But delta is not working with these extractor. When I checked LBW0, I am getting error "The LIS environment is setup incorrectly". According to note 115192, the key fields in tables S001, S001
-
What is the maximum level that a role can be resolved to?
hi folks can anyone tell me what is the maximum level at which expand role works. for example if i have a role which is then having 3 roles, each role has 2-3 users. will expand role work in this scenario? Also plz tell me why expand role does not wo
-
Hello, Is it possible to use field-symbols in classes? When I try to declare field-symbol in class like other variable, appears an error. Or may be it is possible to use something instead of field-symbols? Great thanx in advance!
-
Captivate 6 video files not loading on share point 2013
Hello, I use Adobe Captivate 6 and have courses that I'm loading to a share point site for learners to access. I worked off of my C: drive, then copied the published folders on a shared drive. I then linked the html URL to play the course. When the c
-
Can you put Chapter Header/Footer Sections in an iBook?
I have spent an incredible amount of effort to find a way to display Title Chapter Headers / Title Chapter Footer (I have also tried doing it through css as well). I know on bottom of an ibook page you can tap on the brown scroller and it will displa