import java.util.Scanner;18m : 16s to test end /** * Replace this JavaDoc comment for the purpose of this class */ public class Solution { /** * Gets data from standard input */ private Scanner input; /** * Start the execution of the solution18m : 16s to test end * @param args Command line arguments */ public static void main(String args[]) { Solution solution = new Solution(); solution.run(); } /** * Run the solution. This method is called from main() */ public void run() { // Create object to read data from standard input input = new Scanner(System.in); // Total amount of money recolected by Carrillo Store double carrilloTotal = 0.0; // Total amount of money recolected by Sardinal Store double sardinalTotal = 0.0; // Total amount of money recolected by Liberia Store double liberiaTotal = 0.0; // Amount of times that Carrillo appears in the standar input double carrilloTimes = 0.0; // Amount of times that Sardinal appears in the standar input double sardinalTimes = 0.0; // Amount of times that Liberia appears in the standar input double liberiaTimes = 0.0; // While there is something to read while ( input.hasNext() ) { // Save the date in a variable String date = input.next(); // Save the store Location String storeLocation = input.next(); // Get the amount of money recolected by that store double salesAverage = input.nextDouble(); // If the location is Carrillo if (storeLocation.equals("Carrillo")) { // Create an instance of a Store Store carilloStore = new Store(date,storeLocation,salesAverage); // Make the calcs according to Carrillo carrilloTotal = carrilloTotal + carilloStore.calculateMount(); // Add one to the counter because Carrillo appeard carrilloTimes++; } // If the store is Sardinal if (storeLocation.equals("Sardinal")) { // Create an instance of a Store Store sardinalStore = new Store (date,storeLocation,salesAverage); // Make the calcs corresponding to Sardinal sardinalTotal = sardinalTotal +sardinalStore.calculateMount(); // Add one to the counter because SARDINAL apperead sardinalTimes++; } // If the store is Liberia if (storeLocation.equals("Liberia")) { // Create an instance of the store Store liberiaStore = new Store (date, storeLocation, salesAverage); // Make the calcs corresponding to that store liberiaTotal = liberiaTotal + liberiaStore.calculateMount(); // Add one to the counter because Liberia appeard liberiaTimes++; } } // Print table according to the specifications // If the Months are December - April or June // If (month == 1 || month == 2 || month == 3 || month ==4 || month == 7) // { // Print in the high Season Column and print 00000 on the low Season one // System.out.print("Carillo"); // System.out.printf("%,2f%n", carrilloTotal / carrilloTimes); // System.out.print("Liberia"); // System.out.printf("%,2f%n", liberiaTotal / liberiaTimes); // System.out.print("Sardinal"); // System.out.printf("%,2f%n", sardinalTotal / sardinalTimes); // } // Otherwise is low season so print low Seasonn column printHeader(); System.out.print("Carillo "); System.out.printf("%,2f%n", carrilloTotal / carrilloTimes); System.out.println("Liberia " + liberiaTotal / liberiaTimes); System.out.println("Sardinal " + sardinalTotal / sardinalTimes); // Close the standard input input.close(); } public void printHeader() { System.out.println("TIENDA BAJA ALTA"); System.out.println("=============== =============== ==============="); } } /** * The class that controls the Store * */ class Store { // The salesAverage of that Store private double salesAverage = 0; // The date of the Report private String date = null; // Knows where the store is located private String storeLocation = null; /** * The constructor to initalize a store giving the encessary parameters * it includes the date, the location, and the salesAverage * @param the date of the report * @param the location of the Store * @param the amount of money, that the report informs */ public Store (String date,String storeLocation,double salesAverage) { // Initialize all the variables, according to the paramaters given this.date = date; this.storeLocation = storeLocation; this.salesAverage = salesAverage; } /** * Function to recover the value of the sales reported * to that specific store * @return the amount of money reported that they */ public double calculateMount() { return this.salesAverage; } }