UNB/ CS/ David Bremner/ teaching/ java/ BangBuck.java
import ccj.*;

public class BangBuck 
{  public static void main(String[] args)
   {  String bestName = "";
      double bestPrice = 0;
      int bestScore = 0;

      boolean done = false;
      while (!done)
      {  String nextName;
         double nextPrice;
         int nextScore;

         System.out.print("Please enter the model name: ");
         nextName = Console.in.readLine();
         System.out.print("Please enter the price: ");
         nextPrice
            = Numeric.parseDouble(Console.in.readLine());
         System.out.print("Please enter the score: ");
         nextScore
            = Integer.parseInt(Console.in.readLine());

         if (nextPrice != 0)
         {  if (bestPrice == 0 || nextScore / nextPrice
               > bestScore / bestPrice)
            {  bestName = nextName;
               bestScore = nextScore;
               bestPrice = nextPrice;
            }
         }

         System.out.print("More data? (Y/N) ");
         String answer = Console.in.readLine();
         if (!answer.toUpperCase().equals("Y"))
            done = true;
      }

      System.out.println("The best bang for the buck is "
         + bestName
         + " (Score: " + bestScore
         + " Price: " + bestPrice + ")");   
   }
}