import java.util.Scanner; /** * Replace this JavaDoc comment for the purpose of this class */ public class Solution { /** * Gets data from standard input */ private Scanner input; /** * Reference to the current Branch Office being processed */ private Branch branch = null; /** * Start the execution of the solution * @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); input.useDelimiter("[\\s\\/]+"); int day = 0; int month = 0; int year = 0; double totalSale = 0.0; double highAverage = 0.0; double lowAverage = 0.0; System.out.printf("%-15s %15s %15s%n", "TIENDA", "BAJA", "ALTA"); //Print head with format System.out.println("=============== =============== ==============="); //Print "=" sign needed this.branch = new Branch(day, month, year, totalSale, highAverage, lowAverage); this.branch.calculateLowAverage(); this.branch.calculateHighAverage(); //Print the output needed for each branch name System.out.printf("%-15s %15.2f %15.2f%n", "Carrillo", this.branch.calculateLowAverage(), this.branch.calculateHighAverage()); System.out.printf("%-15s %15.2f %15.2f%n", "Liberia", this.branch.calculateLowAverage(), this.branch.calculateHighAverage()); System.out.printf("%-15s %15.2f %15.2f%n", "Sardinal", this.branch.calculateLowAverage(), this.branch.calculateHighAverage()); // Close the standard input input.close(); } } /** * The branches with its arributes basen on the input */ class Branch { private int day = 0; private int month = 0; private int year = 0; private double totalSale = 0.0; private double highAverage = 0.0; private double lowAverage = 0.0; public Branch(int day, int month, int year, double totalSale, double highAverage, double lowAverage) { this.day = day; this.month = month; this.year = year; this.totalSale = totalSale; } /** * Calculate the average of the high season */ public double calculateHighAverage() { return this.highAverage; } /** * Calculate the average of the low season */ public double calculateLowAverage() { return this.lowAverage; } }