{ Visit: http://g-lts.info/ for more code! } package first; import java.util.Scanner; class Product { private String name; private int score; private double price; public Product() { name = ""; score = 0; price = 1; } public void printData() { System.out.println("Name : " + name); System.out.println("Price : " + price); System.out.println("Score : " + score); } public void read() { Scanner in = new Scanner(System.in); System.out.println("Please enter the product name : "); name = in.nextLine(); System.out.println("Please enter the product price : "); price = in.nextDouble(); System.out.println("Please enter the product score : "); score = in.nextInt(); } public boolean is_better_than ( Product other ) { if ( (score/price) > (other.score/other.price) ) return true; return false; } } // Main.. public class Main { public static void main (String[] args) { Scanner in = new Scanner(System.in); Product best = new Product(); // Το βέλτιστο προϊόν. boolean more = true ; while ( more ) { Product current = new Product(); // Αντιπροσωπεύει το τρέχω προϊόν. current.read(); if ( current.is_better_than(best) ) { best = current ; } System.out.println("More data ? (1=Yes , 2=No) :"); int answer = in.nextInt(); if ( answer != 1 ) more = false; in.nextLine(); } best.printData(); } } { Visit: http://g-lts.info/ for more code! }