Output not what I want, please try and help, code supplied... :-)

Hello everyone, please help me if u can, Im desperate. Essentially wot Im tryin to do, is create a cd collection program, whereby details of the cd are entered (price, quantity, title and artist) and I would like to return statistical data on the cd collection, such as total number of cds, most expensive and cheapest cds etc. As you can I see I have used arrays to find out the cheapest cd and most expensive cd, it seems to compile k but Im not getting the results/output I want. Its displaying the price fine, but I also want the quantity, title and artist details to be outputted as well, like I do in the cd list using the cdDetails method. Ive tried many ways but still cant do it.
If anybody can help please do if you've got a minute, I will gladfully reward you with duke dollars.
Below is the latest edition of my code:
Thanks in advance,
Larry
import avi.*;
public class CDCollection
private String title = "Unknown";
private String artist = "Unknown";
private int quan = 0;
private double price = 0;
CDCollection(double cdPrice, int cdQuan, String cdTitle, String cdArtist)
title = cdTitle;
artist = cdArtist;
quan = cdQuan;
price = cdPrice;
public double getPrice()
return this.price;
public static double findHighest(CDCollection[] cds)
double highestSoFar = -1; // lower than any valid
for (int i = 0; i < cds.length; i++)
if (cds.getPrice() > highestSoFar)
          highestSoFar = cds [i].getPrice();
return highestSoFar;
public static double findLowest(CDCollection[] cds)
double lowestSoFar = 1000; // lower than any valid
for (int i = 0; i < cds.length; i++)
if (cds[i].getPrice() < lowestSoFar)
          lowestSoFar = cds [i].getPrice();
return lowestSoFar;
public void cdDetails(Window screen)
     screen.write("�"+price+"\t"+quan+"\t"+title+"\t"+artist+"\n");
class CDMain
public static void main(String[] args)
     Window screen = new Window ("CDMain", "bold", "black", 14);
screen.showWindow();
     screen.write("CD List:\n\n");
CDCollection[] cds = new CDCollection[3];
cds[0] = new CDCollection (10.99,11,"All Killer No Filler","Sum 41");
cds[0].cdDetails(screen);
cds[1] = new CDCollection (12.99,8,"The best of","Sting");
cds[1].cdDetails(screen);
cds[2] = new CDCollection (13.99,4,"Best of","Beegees");
cds[2].cdDetails(screen);
double highest = CDCollection.findHighest(cds);
screen.write("\nThe most expensive cd is: �"+highest+"");
double lowest = CDCollection.findLowest(cds);
screen.write("\nThe cheapest cd is: �"+lowest+"");

The findLowest method should return the instance with the lowest
price, not [only] the lowest price. That way you would
have your information.
public CDCollection double findLowest(CDCollection[] cds)
    CDCollection lowest;
    if (cds.length>0) {
        lowest = cds[0];
        for (int i=1; i<cds.length; i++) {
             if (cds[ i].getPrice() < lowest.getPrice()) {
                  lowest = cds[ i];
    } else {
         // no cds --> no lowest --> return null
         lowest = null;
    return lowest;
}findHighest: same struggle.

Similar Messages

  • I ordered a ringtone that came as a song and did not appear in a position to be added.  It did not show up but came through as a song and asking me to add it to a playlist.  This is not what I wanted to do and I promptly follow the prompt to "Buy"

    I ordered a ringtone that came as a song and did not appear in a position status to be added.  It did not show up but came purchased as a song and now asking me to add it to a playlist.  This is not what I wanted to do and I promptly follow the prompt to "Buy more options" to get what I thought was a ringtone.  Please help!

    The ONLY place to buy a ready made ringtones is from the iphone itself from the itunes app, then "More">"Ringtones"
    If you bought from your computer, then you need to create the ringtone.  You can create a ringtones from just about any song/sound file for free.
    Google will find several ways to do this.

  • ITunes does not detect my iPod-- please read and help?!

    I tried all the help Apple told me to do. I reset my iPod(didn't work) and then I downloaded the newest version of iTunes. That didn't work either. My iTunes still does not detect my iPod. The newly downloaded iTunes was at least supposed to tell me that my iPod was "corrupted" but it didn't. So... I'm not sure that it is. But that is the only reason Apple tells you could cause this. So yeah, I'm pretty lost right now! Does anybody know anything to help(by the way, I own a 5th generation iPod nano)? Thanks

    Take a look at this web page and see if it helps. Some of the suggestions are ones you say you've already tried, but there are other suggestions, one of which may help:
    iPod missing in "My Computer" or in iTunes on Windows
    Good luck.

  • I am using and iphone 4 on ios 7.0.6 and i recently installed whats and its says "could not connect to whats app service. please try again later

    i am using and iphone 4 on ios 7.0.6 and i recently installed whats and its says "could not connect to whats app service. please try again later

    According to WhatsApp, service is back up & running. Did have a 4 hour outage:
    https://twitter.com/wa_status/status/437358172983279616

  • I turn off my whats app lasseen time stamp more than 24 hours ago and now i can't turn it on it sees " could not connect to whats app services please try again latter"  i try deleting the app  and changing the calendar and still didnt worrk

    I turn off my whats app lasseen time stamp more than 24 hours ago and now i can't turn it on it sees " could not connect to whats app services please try again latter"  i try deleting the app  and changing the calendar and still didnt worrk

    Ok - an update ...
    Managed to get the phone to backup to iCloud, so decided to risk the "Factory" reset.
    Took the reset option including delete all data and crossed fingers.
    It took a while to resotre from iCloud, but everthing seems to be back and ...
    Bluetooth now working agaim.
    Backup to Computer working again.
    And somewhat to my surprise, GMail in the mail app is working again. (The surprise being that the implication of other posts was that this was a 6.1.3 fundamental bug)
    Still no idea why the iPhone was corrupted - but at least the "Factory" reset seems to have recovered the situation.

  • Hello dps team,  A few weeks ago we renewed our dps licence. Now we want to release our newest issue but we can't. Following error message appears "At the attempt to release the folio creates an error. The process could not be started. Please try again la

    Hello dps team,
    A few weeks ago we renewed our dps licence. Now we want to release our newest issue but we can't. Following error message appears "At the attempt to release the folio creates an error. The process could not be started. Please try again later."
    Is there a problem with our dps version or any maintenance work at the servers from Adobe?
    Best,
    Oliver

    Hi Oliver,
    Please login to your DPS dashboard and contact support by clicking "Contact support" at the bottom left
    Thanks
    Lohrii

  • HT1218 3TB Timecapsule version 7.6.4 is CONSTANTLY losing WAN connection.  Comcast is our carrier, and I've ruled out the modem as it downloads at 30mbs consistently.  Want to try and update firmware of Timecapsule, but it will not display an "Update" ico

    3TB Timecapsule version 7.6.4 is CONSTANTLY losing WAN connection.  Comcast is our carrier, and I've ruled out the modem as it downloads at 30mbs consistently. 
    Want to try and update firmware of Timecapsule, but it will not display an "Update" icon.
    Grrrrr.....makes me miss my stupid PC set up as I could force it to do what I want!
    Intermittent connection screws up Netflix, VOIP phone, Amazon, Streaming music via Spotify/Pandora, general internet access.....whole family is ****** off.
    Any tips/tricks/ideas???
    dave

    Downgrade firmware to 7.6.1 .. as the latest is just lousy.
    It is easy to downgrade.. hold down the option key whilst you click the version number. in Macs.. lots of stuff is hidden behind an option key.
    I also strongly recommend a factory reset and use all SMB names.. not apple type names..
    ie TC name.. TCgen4
    Wireless name TCwifi (or give names to both bands.. TC24ghz and TC5ghz).
    That helps all the non-apple part of the world.. connect.
    Also Mavericks has now changed over to SMB as well. So even Mac is now windows networking.
    Generally these two things. .7.6.1 firmware and SMB names will fix it.. if not post again as is another step that is possible.. controlling the WAN speed of the TC.

  • Apple, please fix this bug.  Sending scanned images to "Pictures" is not what I want nor what I was able to do in every previous operation system.   I want to save all scanned items in a specific folder - NOT "PICTURES"  Please fix this bug NOW!

    Apple, please fix this bug.  Sending scanned images to "Pictures" is not what I want nor what I was able to do in every previous operation system.   I want to save all scanned items in a specific folder - NOT "PICTURES"  Please fix this bug NOW!

    I only use Image Capture, so I can't speak for other software.
    Here is how I select a Scan To destination:
    If you are using the minimal details screen, you should have the same submenu to the left of the page size.

  • I download a file in the torrent site which is MP4 but unfortunately i tried to delete it but i can not. but all the files that i have is easily to delete only MP4 files i can't delete in the download foldeer please try to help dont know what to do please

    i download a file in the torrent site which is MP4 but unfortunately i tried to delete it but i can not. but all the files that i have is easily to delete only MP4 files i can't delete in the download foldeer please try to help dont know what to do please

    Well you can sync your iPod/iPhone to yur computer or laptop then take the photos off of your iPod like taking photos of of a SD card (from a normal camera) or off of a USB..! Good Luck. plz tick this saying This solved my question if it helps you.

  • HT1937 I can't get do this iCloud, I just do not get it! I looked at so many instructions to try and help me and nothing seems to work. All I want to do is copy and paste all my photo's and videos as I used to before the iphone updated to iOS. Can you hel

    I can't do this iCloud thing, I just do not get it! I looked at so many instructions to try and help me and nothing seems to work. All I want to do is copy and paste all my photo's and videos as I used to before the iphone updated to iOS. Can you help me? P
    I've tried looking for the devise in My computer but all it says is iCloud. I really want to find the DMIC folder and I don't know how!

    Emma Norton wrote:
    I've tried looking for the devise in My computer but all it says is iCloud.
    You should not see anything labeled iCloud in Windows Explorer.

  • When opening a new tab, it opens onto a search engine, which is not what i want it to do. How do i resolve this and change it back to just a black page?

    when opening a new tab, it opens onto a search engine, which is not what i want it to do. How do i resolve this and change it back to just a black page?

    A new tab opens by default as a blank tab (about:blank).
    If that isn't the case then an extension has changed that behavior.
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode

  • The image came up on my screen saying that I need to connect my iPod to iTunes, but I have a passcode, so it won't allow me to. And I want to try and turn it off, but my touch screen doesn't seem to be working either. HELP!

    The image came up on my screen saying that I need to connect my iPod to iTunes, but I have a passcode, so it won't allow me to. And I want to try and turn it off, but my touch screen doesn't seem to be working either, so I can't even turn it off since you need to "slide to power off." HELP! I'm leaving on Thursday morning for six and a half weeks, and I absolutely need my iPod with me. I was just at the Apple store today for problems I was having with ANOTHER product, and I don't really want to drive all the way out to where my nearest store is (which is not very near) if I can figure this out at home. My iPod was working totally fine earlier today and last night, so I don't know what happened! Please, please, PLEASE HELP!

    Now it's allowing me to reboot (hold down power button and home button and restart), but every time it just comes up to the same thing: the connect to iTunes page. Which is not possible. And I refuse to restore my iPod. PLEASE HELP.

  • Oracle8i, OAS, NT - Can not service this request, please try again later

    Hello,
    I've installed OAS 4.0.7.1 (including the patch download from Oracle) and Oracle8i in two separate Oracle_Homes on an NT 4, sp4 machine.
    I've managed to get the JWEB, Livehtml and JCO samples running, however the PLSQL and CWEB samples won't run...giving a really useful error message of:
    'Can not service this request, please try again later'
    oh, and I have installed the PLSQL toolkit etc.
    I've previously had an OAS 4.0.5 app up and running fine on NT 4 sp4, against an 8.0.4 DB.
    Has anyone got any ideas on what the problem is with the PLSQL/CWeb cartridges?
    thanks
    David
    [email protected]

    Hi David,
    This could be because of low physical & virtual memory, but if you can post errors that are in log file(wrb.log) it will help to
    solve the problem
    Ganesh

  • [svn] 3526: The call to the TestNG task in the configuration test framework had haltOnFailure set to true which is not what we want .

    Revision: 3526
    Author: [email protected]
    Date: 2008-10-08 14:21:40 -0700 (Wed, 08 Oct 2008)
    Log Message:
    The call to the TestNG task in the configuration test framework had haltOnFailure set to true which is not what we want. Failures will get logged to the database at which point we can review them.
    Also fix a failing test.
    Modified Paths:
    blazeds/trunk/qa/apps/qa-regress/testsuites/config/build.xml
    blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/messagingService/jms/NoJNDINameT est/error.txt
    blazeds/trunk/qa/apps/qa-regress/testsuites/config/tests/messagingService/jms/NoJNDINameT est/services-config.xml

    I have a standard Ant build script for signing a jar file. I import it into my master Ant build files with
    <import file="Sign.xml"/>
    and then in my master Ant script I setup the name of the jar file e.g.
    <property name="jar-file" value="${fun}/FunApplet.jar"/>
    and then invoke a target
    <target name="sign-jar" depends="jar, sign">
    </target>
    Since this target (sign-jar) depends on target 'jar' and target 'sign' it executes the 'jar' target and then the 'sign' target that is contained in Sign.xml.

  • ITunes cannot sync photos to the iPhone "iPhone" because your iPhoto Library is not yet available. Please try again later.

    Ive been trying to sync my phone and it shows this:
    iTunes cannot sync photos to the iPhone “iPhone” because your iPhoto Library is not yet available. Please try again later..............
    When i connect my phone iPhotos comes up and shows my photos and i even tried syncing my photos to my laptop and even deleting them and this message keeps popping up. it just backs up then says downloading photos on iTunes then that error message comes out.

    Same thing on iOS 8.1.2, on my iPad and iPhone. Unlikely to be the devices ....

Maybe you are looking for

  • Can I back up the HDD and an External drive at the same time?

    Hi - I have a 250Gb HDD (tiny!), but I have just bought myself 2 x 2Gb external drives which I have now formatted. I intend to move my complete iTunes library on to 1 of the externals and I want to use the other external as a back-up for both the HDD

  • Problem with hyperlinks.

    Hi all, I am running Adobe Indesign CS6 and having trouble with my hyperlinks. When I export it as a .SWF, I try clicking on my hyperlinks but nothing happens. What should I do?? Thanks

  • My new Skype Number is no longer in service?

    I picked a skype number when I set up Skype.  It is [redacted to protect privacy].  Now it says that it is no longer in service.  Help Post transferred to create its own new thread (topic). Subject/title amended accordingly. First things, first: for

  • Restored Ipod but it won't transfer my library back to Ipod

    I've restored my Ipod, because it wasn't picking up the new music i recently put into my library, so there's nothing on it, and when i try to sync it with my library now, it says ipod sync complete but nothing goes on the ipod. it is still empty!! pl

  • I've created a shared MobileMe calendar & can see the events my dad has added but not he can't see mine

    None of the events that I've added show up on his version of the shared calendar, whether they were created before I shared it with him or after. But the ones he's created show up in mine. We've refreshed both calendars multiple times! Seems to defea