My bubble sort doesn't work, and does anyone know

how to count and print the scores of a certain grade.... all the 90's with a's, all the 80's with b's etc.... This is my first java program with two classes. I've been messing with it for about 24hours over the last week. :O. Any suggestions?
import java.util.Scanner;
public class GradeSort {
     public static void main(String [] args){
          //Scanner keyboard = new Scanner(System.in);
          System.out.println("How many students took the test?");
          Scanner kbd = new Scanner(System.in);
          int NUM_STUDENTS = kbd.nextInt();
          double [] grades = new double[NUM_STUDENTS];//Assn array
          readReadingsInto(grades);
          System.out.printf( "\nThe average is %.3f%n", average(grades));
          print(grades);}
          private static void readReadingsInto(double [] array){
               Scanner keyboard = new Scanner(System.in);
               for (int i =0; i < array.length; i++) {
               System.out.print("enter grade # " + (i+1)+ "/" );
          array[i] = keyboard.nextInt();
     public static double average(double [] anArray){
          double sum = 0.0;
          for (double item : anArray){
               sum += item;
          return sum/anArray.length;
public static void bubbleSort ( double [] anArray )
for (double i = anArray.length-1; i > 0; i-- )
for ( int j = 0; j < i; j++ )
if ( anArray[j] > anArray[j+1] )
double temp = anArray[j];
anArray[j] = anArray[j+1];
anArray[j+1] = temp;}
public static void print(double [] arr) {
     for (int i = 0; i < arr.length; i++){
          Grade gRade = new Grade(arr);
          System.out.println("Reading #" + (i+1)+" " + arr[i] + " " + gRade.letter() );
          //Grade gRade = new Grade(reading);
          //System.out.println( gRade.letter() );
          //System.out.print ( grades[1] );
public class Grade {
     public static final double MIN = 0.0;
     public static final double MAX = 100.0;
     public Grade(double gRade){
          if (gRade < MIN || gRade > MAX){
               System.err.println("Grade(): bad argument recievived: " + gRade);
          } else {
               myValue = gRade;
public String letter(){
     if (myValue < MIN || myValue > MAX){ return "error";}
else if (myValue >= 90){return "A";}
else if (myValue >= 80){return "B";}
else if (myValue >= 70){return "C";}
else return "Fail";     }
private double myValue;

Let me see if I can fix the formatting for you. The bubble sort, isn't sorting? The print after the sort is in the same order as I input the data.
import java.util.Scanner;
public class GradeSort {
     public static void main(String [] args){
          //Scanner keyboard = new Scanner(System.in);
          System.out.println("How many students took the test?");
          Scanner kbd = new Scanner(System.in);
          int NUM_STUDENTS = kbd.nextInt();
          double [] grades = new double[NUM_STUDENTS];//Assn array
          readReadingsInto(grades);
          System.out.printf( "\nThe average is %.3f%n", average(grades));
          print(grades);}
          private static void readReadingsInto(double [] array){
               Scanner keyboard = new Scanner(System.in);
               for (int i =0; i < array.length; i++) {
               System.out.print("enter grade # " + (i+1)+ "/" );
          array[i] = keyboard.nextInt();
     public static double average(double [] anArray){
          double sum = 0.0;
          for (double item : anArray){
               sum += item;
          return sum/anArray.length;
public static void bubbleSort ( double [] anArray )
        for (double i = anArray.length-1; i > 0; i-- )
          for ( int j = 0; j < i; j++ )
              if ( anArray[j] > anArray[j+1] )
                    double temp = anArray[j];
                    anArray[j] = anArray[j+1];
                    anArray[j+1] = temp;}
public static void print(double [] arr) {
     for (int i = 0; i < arr.length; i++){
          Grade gRade = new Grade(arr);
          System.out.println("Reading #" + (i+1)+" " + arr[i] + " " + gRade.letter() );
          //Grade gRade = new Grade(reading);
          //System.out.println( gRade.letter() );
          //System.out.print ( grades[1] );
The other class is:
public class Grade {
     public static final double MIN = 0.0;
     public static final double MAX = 100.0;
     public Grade(double gRade){
          if (gRade < MIN || gRade > MAX){
               System.err.println("Grade(): bad argument recievived: " + gRade);
          } else {
               myValue = gRade;
public String letter(){
     if (myValue < MIN || myValue > MAX){ return "error";}
else if (myValue >= 90){return "A";}
else if (myValue >= 80){return "B";}
else if (myValue >= 70){return "C";}
else return "Fail";     }
private double myValue;

Similar Messages

  • My iPod's headphone jack isn't working anymore, when i put my headphones in , the left l, My iPod's headphone jack isn't working anymore, when i put my headphones in , the left earphone doesn't work. Does anyone know if this can be fixed ?

    My iPod nano 3rd generation headphone jack isn't working anymore, when i put my headphones in , the left earphone doesn't work. Does anyone know if this can be fixed ?

    Hi Mr.Acevedo329!
    I have an article here for you that can help you troubleshoot the issues you are experiencing. That article can be found right here:
    iPod troubleshooting basics and service FAQ
    http://support.apple.com/kb/ts1382
    Specifically, you will want to take note of this section:
    The headphones don't work
    If your iPod's headphones don't work or have static or garbled audio, try connecting them to any other 3.5 mm stereo headphone jack, like the one on your computer. If the issue with the headphones persists, replace them. For an iPod under warranty, you can order a replacement online. Otherwise, check out the cool headphones at the Apple Online Store. If the issue appears to be with the iPod, try resetting it. If that doesn't work, then restore iPod with the latest iPod software using iTunes 7 or later.
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • I used mactheripper to rip my DVDs so I could store them on my mac.  However since upgrading to lion x os mactheripper doesn't work. Does anyone know of a free alternative that works on lion x os?  Thanks

    I used mactheripper to rid my DVDs so I could store them on my mac.  Since upgrading to lion x os mactheripper doesn't work.  Does anyone know of a free alternative that works with lion x os?  Thanks

    Try what Terence Devlin posted in this topic:
    Terence Devlin
    Apr 14, 2015 11:21 AM
    Re: Is Iphoto gone ? i want it back!
    in response to Johannes666
    Recommended
    Go to the App Store and check out the Purchases List. If iPhoto is there then it will be v9.6.1
    If it is there, then drag your existing iPhoto app (not the library, just the app) to the trash
    Install the App from the App Store.
    Sometimes iPhoto is not visible on the Purchases List. it may be hidden. See this article for details on how to unhide it.
    http://support.apple.com/kb/HT4928
    One question often asked: Will I lose my Photos if I reinstall?
    iPhoto the application and the iPhoto Library are two different parts of the iPhoto programme. So, reinstalling the app should not affect the Library. BUT you should always have a back up before doing this kind of work. Always.

  • L have to have Quicktime loaded to import video to Photoshop CS4 but it doesn't work. Does anyone know why??

    Hello there
    Can anyone tell me how to import video into Photoshop CS4 as l was told to download Quicktime 7.1 or later but this hasn
    not worked. l have read that it is probably that l have not got the right codex but which one is it......If you have an idea or could point me in the right direction this would be really helpful...
    many thanks
    seannybro

    Many Thanks for the reply, Maybe l didn't word it correctly as l've been searching for days now for a solution,sorry, but l have just found out while watching tutorials on a education program that you can actual edit each frame in a video in Photoshop by importing the video into it. In these tutorials they said you have to download Quicktime 7.1 or later in order for this to work and then you can go through every frame of your video and change it, draw on it, do mainly anything you what, basically what you can do on a photo you can do with a video. It works with one of my AVI,files but not on any of my others or on any of my MOV. files. l just get a white screen the video is there in the AVI but l can't get MOV. to import. In AVI format it shows no pictures but it is there in the time/animation dilation and l was wondering does anyone know if l need to upload a new codec for it to work or have to switch or activate something for it to work on quicktime......but l have found others with the same problem but there all say upload a new codec but which??
    any help would be really appreciated
    Seannybro
    (If your wondering how too try changing your workspace from ESSENTIALS to VIDEO the icon is in the right hand corner near the close down button in Photoshop and double click on the grey interface (a photo uploads) to get to upload your videos from files then you should be able to upload from there....Import in the file menu doesn't work...hope this helps you. If it works for you then l must be going wrong somewhere....enjoy:)

  • TS1702 Can anyone help? For no reason, I cannot open any of my apps.  I can open everything else, just not apps.  I have turned the ipad on and off several times, this doesn't work.  Does anyone know what to do and why this has happened?

    Hello, for some strange reason I cannot open any of the apps I have.  I have tried turning the ipad on and off and this doesn't work.  I can open everything else (videos, camera, etc) just no apps.  Can anyone help please?

    If it's the apps that you've downloaded from the App Store, but not the Apple built-in ones, then try downloading any free app from the store (as that appears to reset something) and then re-try them - the free app can then be deleted.
    If it's all apps including Apple's then try closing them all completely and then see if they work when you re-open them : from the home screen (i.e. not with any app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of each app to close them, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • I've only had my iphone 5s for a week. I keep getting an error message of "Server has stopped responding."  I need the server to work. Does anyone know if there is a "fix" for the problem? Other wise, I probably best return for a refund and get a Samsung.

    I've only had my iphone 5s for a week. I keep getting an error message of "Server has stopped responding."  I need the server to work. Does anyone know if there is a "fix" for the problem? Other wise, I probably best return for a refund and get a Samsung.  Thanks

    sandyzotz wrote:
    Other wise, I probably best return for a refund and get a Samsung.
    Unlikely.  Based on the complete lack of detail of the issue provided it is entirely possible the same issue would occur.
    Unless and until the user provides some actual details of the problem, there is nothing the indicate that the issue is with the iPhone.

  • Hey when ever i download and install Itunes then i open it says error finding folder please re download and I tried a tons of times and it didn't work. Does anyone know how to fix this?

    Hey when ever i download and install Itunes then i open it says error finding folder please re download and I tried a tons of times and it didnt work. Does anyone know how to fix this?

    Hi Beege140,
    I have an article for you that will help you address this launch issue with iTunes:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

  • I have a macbook pro4.1 and the sound chip in it failed. My speakers and microphone no longer work. Does anyone know of an external speaker and microphone set that plugs into the USB port so I can continue to use both of these functions?

    I have a macbook pro4.1 and the sound chip in it failed. My speakers and microphone no longer work. Does anyone know of an external speaker and microphone set that plugs into the USB port so I can continue to use both of these functions and not have to pay to have the entire main board replaced. Preferably something under $100.

    I don't think you're likely to find a set of external speakers that come with a microphone and plug directly into a USB port. There are USB audio cards that look like tiny flash drives but have microphone and headphone ports in them, to which you can connect a typical two-plug Windows PC headset with a microphone, or else you can connect external speakers and a stand-alone microphone. Those adapters typically cost under $10. I don't know anything about the quality of sound that can be expected from them.
    I have a Griffin iMic, which is much the same idea but larger, a bit more expensive (retail~$40), and perhaps delivers somewhat better sound quality (I hope so, but I don't know because I've never had occasion to try one of the little ones).
    http://www.google.com/products/catalog?oe=UTF-8&hl=en&client=safari&q=usb+sound+ card&um=1&ie=UTF-8&tbm=shop&cid=9618463009759678039&sa=X&ei=tgQoT5zYOMfZ0QHkiICw Ag&ved=0CHcQ8gIwAQ
    http://compare.ebay.com/like/320779457703?var=lv&ltyp=AllFixedPriceItemTypes&var =sbar

  • I am trying to print labels from my address book, and when I change it to have the first names first, only some names work.  Does anyone know what the problem is or how to fix it?

    I want to print labels from my address book, but when I try to put first names first, only some will work.  Does anyone know why this is happening and how to fix it?

    Hi MollyPhloot07,
    I'm glad you found the coupons.com app and you might also want to take a look at the GroceryIQ app from the same company.  Please note that at this time, printing is only support from iPad to HP wireless inkjet printer.  That's most likely the reason why your Canon isn't displaying when attempting to print.  The other way to go might be emailing the coupons you want to your email address, then open that email and print from a conventional desktop or laptop computer.
    Hope this helps!
    Coupon Support

  • Hi, i have a problem that my macBook pro keys suddenly stopped working. The power button,volume keys, brightness keys and shortcuts do not work. Does anyone know why or how i can fix this problem?

    hi, i have a problem that my macBook pro keys suddenly stopped working. The power button,volume keys, brightness keys and shortcuts do not work. Does anyone know why or how i can fix this problem?

    hi, i have a problem that my macBook pro keys suddenly stopped working. The power button,volume keys, brightness keys and shortcuts do not work. Does anyone know why or how i can fix this problem?

  • I have an Iphone 4s that I installed the face button app. After trying to use the first time, my phone locked and stopped working. Does anyone knows how to fix that problem or how to reset this phone?

    I have an Iphone 4S that i installed the face button app. After trying to use it, my phone locked and I cannot get it to work anymore. does anyone knows how to reset this phone and get it working again?

    A reset may help. Tap and hold the Home button and the On/Off buttons for approximately 10-15 seconds, until the Apple logo reappears. When the logo appears, release both buttons.
    No content is affected by this procedure.

  • I just updated to OS X Yosemite Version 10.10.3 because After Effects CS6 would't open anymore. But it still does't work. Does anyone know what to do. Please in simple English, because I'm from Germany.

    I just updated to OS X Yosemite Version 10.10.3 because After Effects CS6 would't open anymore. But it still does't work.
    Does anyone know what to do?
    Please in simple English, because I'm from Germany.
    Thx.

    Thank you so much, Mr. Curtis! I'm not sure exactly how that worked, but it allowed me to get back on both AE and Premiere Pro. 10 points to you!
    Also, for the  other people that may have similar problems and are viewing this forum, definitely try this out. Listen to Jim's advice, don't use the most recent version (which is currectly 5.5.47) - instead try a slightly older one. The one I had installed was version 5.5.24.
    Once again, thank you! You saved my project!

  • When launching PS I get an error 150:30 "licensing for this product has stopped working".  Does anyone know how to fix this?

    When launching PS I get an error 150:30 "licensing for this product has stopped working".  Does anyone know how to fix this? downloaded very recently from Creative Cloud

    Supply pertinent information for quicker answers
    The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

  • My G4 powerbook starts up but with a black screen. The reset button does not work. Does anyone know the keys to press on restart please ?

    My G4 powerbook running OSX 10.3.9 starts up with  a black screen. The reset button is not working. Does anyone know which keys to press on restart please.?

    Try holding the shift key while booting to get Safe mode if possible.
    See links for more info.
    http://support.apple.com/kb/ht1564
    http://support.apple.com/kb/ht1455

  • Passbook is not working on my iPhone 4S. I tried changing the date to 2013, but it's still not working. Does anyone know how to fix this?

    Passbook is not working on my iPhone 4S. I tried changing the date to 2013, but it's still not working. Does anyone know how to fix this?

    This link may be helpful.
    http://support.apple.com/kb/ts2755

Maybe you are looking for

  • Home sharing / Apple TV icon has disappeared from all my apple devices

    Two days ago I could go to my shared MacBook through the Apple TV or Throw up a video or music onto the TV from my iPhone or iPad. Last two days... No icon on any device, no home sharing info on the TV, despite every combination of reset and restore.

  • Comparing columns in table and triggers

    hi masters, i have oracle 10g in Linux and us PL/SQL developer to access database, ia m not a developer, but am assigned task to compare columns in table and associated trigger. let me explain, we have 800 tables, and each table essentially have a tr

  • Solution Manager Key SAP Netweaver 2004s SR2

    Hi,  I am trying to install SAP Netweaver 2004s SR2, Can anyone help me by generating the solution manger key for SAP System ID: RVR Central Instance Host: ravuri Central Instance Number: 00 Thanks ginjupalli

  • Discussion Forum Email Subscriptions

    How do I suppress subscriptions in the Discussion forum. My client does not want to allow users to generate any emails when new messages/threads are posted into any and all forums. Any Ideas?

  • Linking movie to menubuilder flash file

    I have a movie saved as an swf/htm file. On the movie end options I selected, Open URL or file. I tell it to open the menu.swf file which is my menubuilder project. I burn these two files to CD. When the movie ends, it just stops. Then menu doesn't o