lease code in  javas, thank you   Write a program that opens the salesdat.txt file and processes it contents. The program should display the following per store: The total sales for each week. (Should print 5 values - one for each week). The average daily sales for each week. (Should print 5 values - one for each week). The total sales for all the weeks. (Should print 1 value) The average weekly sales. (Should print 1 value) The week with the highest amount in sales. (Should print 1 week #) The week with the lowest amount in sales. (Should print 1 week #) All Values (Total Sales, Average Daily Sales for Each Week, Total Sales for all Weeks, Average Weekly Sales, Highest Amount in Sales, Lowest Amount in Sales)   The file contains the dollars amount of sales that a retail store made each day for a number of weeks. Each line in the file contains thirty five numbers, which are sales numbers for five weeks. The number are separated by space.  Each line in the file represents a separate store.   Please make sure that you: a. Add a class diagram with your submission. b. Add comments to your code in FileIO class. c. Make sure you adequately test your code. d. Provide a user-friendly interface (Console based).   The following is source code public class Driver {  public static void main(String[] args) {   // TODO Auto-generated method stub   FileIO a1 = new FileIO("Z:\\JavaPrograms2\\assignment336b\\src\\Salesdat.txt");   Franchise f = a1.readData();  } } ------------------------------------------ import java.io.*; import java.util.*; public class FileIO {  private String fname = null;  private boolean DEBUG = true;  public FileIO(String fname) {   this.fname = fname;  }  public Franchise readData() {   Franchise a1 = null;   int counter = 0;   try {    FileReader file = new FileReader(fname);    BufferedReader buff = new BufferedReader(file);    String temp;    boolean eof = false;    while (!eof) {     String line = buff.readLine();     counter++;     if (line == null)      eof = true;     else {      if (DEBUG)       System.out.println("Reading" + line);      if (counter == 1) {       temp = line;       a1 = new Franchise(Integer.parseInt(temp));       if (DEBUG)        System.out.println("d  " + a1.numberofstores());      }      if (counter == 2)       ;      if (counter > 2) {          int x = buildStore(a1, (counter-3), line);        if (DEBUG)         System.out.println("Reading Store # "+(counter-2)+" Number of weeks read =  " +  x);        if (DEBUG)        {          System.out.println("Data read:");         a1.getStores(counter-3).printdata();        }      }     }    }    buff.close();   } catch (Exception e) {    System.out.println("Error -- " + e.toString());   }   return a1;  }  public int buildStore(Franchise a1, int counter, String temp) {   Store tstore = new Store();   String s1  =  "";   float sale = 0.0f;   int week = 0;   int day = 0;   StringTokenizer st = new StringTokenizer(temp);      while (st.hasMoreTokens()) {           for(day=0;day<7;day++)           {         s1 = st.nextToken();            sale = Float.parseFloat(s1);            tstore.setsaleforweekdayintersection(week, day, sale);           }           week++;      }   a1.setStores(tstore, counter);

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please code in  javas, thank you
 
Write a program that opens the salesdat.txt file and processes it contents. The program should display the following per store:
The total sales for each week. (Should print 5 values - one for each week).
The average daily sales for each week. (Should print 5 values - one for each week).
The total sales for all the weeks. (Should print 1 value)
The average weekly sales. (Should print 1 value)
The week with the highest amount in sales. (Should print 1 week #)
The week with the lowest amount in sales. (Should print 1 week #)
All Values (Total Sales, Average Daily Sales for Each Week, Total Sales for all Weeks, Average Weekly Sales, Highest Amount in Sales, Lowest Amount in Sales)
 
The file contains the dollars amount of sales that a retail store made each day for a number of weeks. Each line in the file contains thirty five numbers, which are sales numbers for five weeks. The number are separated by space.  Each line in the file represents a separate store.
 
Please make sure that you:
a. Add a class diagram with your submission.
b. Add comments to your code in FileIO class.
c. Make sure you adequately test your code.
d. Provide a user-friendly interface (Console based).
 
The following is source code

public class Driver {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  FileIO a1 = new FileIO("Z:\\JavaPrograms2\\assignment336b\\src\\Salesdat.txt");
  Franchise f = a1.readData();
 }

}

------------------------------------------

import java.io.*;
import java.util.*;

public class FileIO {
 private String fname = null;
 private boolean DEBUG = true;

 public FileIO(String fname) {
  this.fname = fname;
 }

 public Franchise readData() {
  Franchise a1 = null;
  int counter = 0;
  try {
   FileReader file = new FileReader(fname);
   BufferedReader buff = new BufferedReader(file);
   String temp;
   boolean eof = false;
   while (!eof) {
    String line = buff.readLine();
    counter++;
    if (line == null)
     eof = true;
    else {
     if (DEBUG)
      System.out.println("Reading" + line);
     if (counter == 1) {
      temp = line;
      a1 = new Franchise(Integer.parseInt(temp));
      if (DEBUG)
       System.out.println("d  " + a1.numberofstores());
     }
     if (counter == 2)
      ;
     if (counter > 2) {
         int x = buildStore(a1, (counter-3), line);
       if (DEBUG)
        System.out.println("Reading Store # "+(counter-2)+" Number of weeks read =  " +  x);
       if (DEBUG)
       { 
        System.out.println("Data read:");
        a1.getStores(counter-3).printdata();
       }
     }
    }
   }
   buff.close();
  } catch (Exception e) {
   System.out.println("Error -- " + e.toString());
  }
  return a1;
 }

 public int buildStore(Franchise a1, int counter, String temp) {
  Store tstore = new Store();
  String s1  =  "";
  float sale = 0.0f;
  int week = 0;
  int day = 0;
  StringTokenizer st = new StringTokenizer(temp);
     while (st.hasMoreTokens()) {
          for(day=0;day<7;day++)
          {
        s1 = st.nextToken();
           sale = Float.parseFloat(s1);
           tstore.setsaleforweekdayintersection(week, day, sale);
          }
          week++;
     }
  a1.setStores(tstore, counter);
     return week; 
 }
}

---------------------

public class Franchise {
 private Store stores[];
 
 public Franchise(int num) {
   stores = new Store[num];
 }

 public Store getStores(int i) {
  return stores[i];
 }

 public void setStores(Store stores, int i) {
  this.stores[i] = stores;
 }
 public int numberofstores()
 {
  return stores.length;
 }
 
}

----------------------

public class Store {
 private float salesbyweek[][];

 Store() {
  salesbyweek = new float[5][7];
 }

 // getter and setters
 // setsaleforweekdayintersection(int week, int day, float sale)
 public void setsaleforweekdayintersection(int week, int day, float sale) {
  salesbyweek[week][day] = sale;
 }

 public void printdata() {
  for (int i = 0; i < 5; i++)
  {
   for (int j = 0; j < 7; j++)
   {
    System.out.print(salesbyweek[i][j] + " ");
   }
   System.out.println("");
  }
 }
 // float [] getsalesforentireweek(int week)
 // float getsaleforweekdayintersection(int week, int day)
 // businessmethod
 // a. totalsalesforweek
 // b. avgsalesforweek
 // c. totalsalesforallweeks
 // d. averageweeklysales
 // e. weekwithhighestsaleamt
 // f. weekwithlowestsaleamt
 // analyzeresults //call a through f
 // print()
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY