Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Download the Creating Projects in DrJava PDF (instructor\'s version) on how t

ID: 3860190 • Letter: 2

Question

2. Download the Creating Projects in DrJava PDF (instructor's version) on how to create a oject folder that manages multiple java files stored in the same folder. The project folder has the same name as the group java file. You are creating 3 separate java files to be stored in the project folder a. TeamMembersLastNames SectionNoPANo.java contains only the main b. CompanyStores java c. Store.java 3. The fields/class variables are non-static. All methods are non-static excepf for the main0. The main) will instantiate (create) an object of the CompanyStores class and use that object to call start). Make sure you exit main(0 4. The CompanyStores class will have 4 methods: an empty constructor, start) processStorelnfo() and displayStoreStats). You will create a 1D array called myStores at the class level as a null array. The type for this array will be Store a. start) contains a local variable called answer that holds the response to prompt 1. Based orn that response processStoreinfo) and displayStoreStats0 are called or a Thank you ..." message is printed. b. In process Storelnfo0, the user will be prompted for the name of the company and the number of stores. That number gives size to the myStores array. The array will then be populated with information for multiple stores c. displayStoreStats0 has 3 local variables: salesDifference, message, and report that is initialized to the header in the final output specifications. The sales difference is calculated by subtracting a store's projected annual sales from its total quarterty sales. The difference is then used to determine which of 2 messages is stored in the message variable to be printed with the store information. An enhanced for loop is used to access each store's information from the array 5. The Store class will have the set methods to capture the stores information and the get methods to return the captured data a. Code an empty constructor b. Code an overloaded constructor that accepts the location of the store and its manager. Assign c. Code setStoreLctn0 that prompts for the store's location and receives the loop-control value d. Code setManager) that prompts for the managers name and receives the loop-control value e. Code setTotalQtrlySales0 that prompts for each quarter's sales and adds it to a the parameter variables to class variables of the same name. from the loop that calls the set methods in CompanyStores from the loop that calls the set methods in CompanyStores totalQtrtySales variable. It also receives the loop-control value from the loop that calls the set methods in CompanyStores

Explanation / Answer

Given below is the needed code and output for the question. Please do rate the answer if it helped. Thank you.

Store.java

import java.util.Scanner;

public class Store {
  
   private String location;
   private String manager;
   private double quarterlySales[];
   private double projectedSales;
   private Scanner keybd = new Scanner(System.in);

   //empty construtor
   public Store(){
       location = "";
       manager = "";
       quarterlySales = new double[4];
   }
   //overloaded constructor
   public Store(String loc, String mgr){
       location = loc;
       manager = mgr;
       quarterlySales = new double[4];
   }
  
  
   public void setStoreLctn(int i) {
       System.out.print(" Enter the location for store " + i + ": ");
       location = keybd.nextLine().trim();
   }

   public void setManager(int i) {
       System.out.print("Enter the name of the manager for store " + i + ": ");
       manager = keybd.nextLine().trim();
   }

   public void setTotalQtrlySales(int i) {
       String quarter = "" ;
      
       for(int q = 1; q <= 4; q++){
           if(q == 1)
               quarter = "1st";
           else if(q == 2)
               quarter = "2nd";
           else if(q == 3)
               quarter = "3rd";
           else if(q == 4)
               quarter = "4th";
           System.out.print("Enter the sales revenue for the " + quarter + " quarter of store " + i +": " );
           quarterlySales[q-1] = keybd.nextDouble();
          
       }
       System.out.print("What is the projected annual sales for store " + i + "? ");
       projectedSales = keybd.nextDouble();
   }
  
   public String getStoreLctn(){
       return location;
   }
  
   public String getStoreManager(){
       return manager;
   }
  
   public double getProjectedAnnualSales(){
       return projectedSales;
   }
  
   public double getTotalQuarterlySales(){
       double total = 0;
       for(int i = 0; i < 4; i++)
           total += quarterlySales[i];
      
       return total;
   }
}

CompanyStores.java

import java.util.Scanner;

public class CompanyStores {
   private Scanner keybd = new Scanner(System.in);
   private String companyName; //name of the company
   private Store[] myStores; //stores
   //empty constructor
   public CompanyStores(){
      
   }
  
   public void start(){
       String answer;
       System.out.print("Do you want to track the sales performance of your store(s)? Enter 'Y' or 'N': ");
       answer = keybd.nextLine().trim().toUpperCase();
       if(answer.equals("Y")){
           processStoreInfo();
           displayStoreStats();
       }
       else{
           System.out.println("Thank you! Exiting program.");
       }
   }
  
   private void processStoreInfo(){
       System.out.print("What is the name of your company? ");
       companyName = keybd.nextLine().trim().toUpperCase();
       System.out.print("How many stores do you have? ");
       int n = keybd.nextInt();
       myStores = new Store[n];
       for(int i = 0; i < n; i++)
       {
           myStores[i] = new Store();
           myStores[i].setStoreLctn(i+1);
           myStores[i].setManager(i+1);
           myStores[i].setTotalQtrlySales(i+1);      
       }
   }
  
   private void displayStoreStats(){
       String message, report = "";
       double salesDifference;
      
       report += " SALES FOR " + companyName + " AT ALL LOCATIONS ";
       for(int i = 0; i < myStores.length; i++){
           report += " Store: " + companyName + " @ " + myStores[i].getStoreLctn() + " ";
           report += "Manager: " + myStores[i].getStoreManager() + " ";
           report += "Projected Annual Sales: $" +String.format("%,.2f", myStores[i].getProjectedAnnualSales()) + " ";
           report += "Total Quarterly Sales: $" +String.format("%,.2f", myStores[i].getTotalQuarterlySales()) + " ";
           salesDifference = myStores[i].getTotalQuarterlySales() - myStores[i].getProjectedAnnualSales();
           report += "Difference: $" +String.format("%,.2f", salesDifference) + " ";
           if(salesDifference >= 0){  
               report += "Performance: KEEP UP THE GOOD WORK! Your store is ahead of your annual sales ";
               report += "projections or right on target. ";
           }
           else{
               report += "Performance: WARNING! Your store sales are below annual projections. ";
           }
       }
      
       System.out.println(report);
   }
}

Main.java


public class Main {
  
   public static void main(String[] args) {
       CompanyStores company = new CompanyStores();
       company.start();
   }
}

output

Do you want to track the sales performance of your store(s)? Enter 'Y' or 'N': y
What is the name of your company? tandem
How many stores do you have? 2

Enter the location for store 1: DeZavala & I10
Enter the name of the manager for store 1: Carmen Vasquez
Enter the sales revenue for the 1st quarter of store 1: 25000
Enter the sales revenue for the 2nd quarter of store 1: 28000
Enter the sales revenue for the 3rd quarter of store 1: 30000
Enter the sales revenue for the 4th quarter of store 1: 29000
What is the projected annual sales for store 1? 100000

Enter the location for store 2: 281 & 1604
Enter the name of the manager for store 2: Diego Garza
Enter the sales revenue for the 1st quarter of store 2: 30000
Enter the sales revenue for the 2nd quarter of store 2: 25000
Enter the sales revenue for the 3rd quarter of store 2: 28000
Enter the sales revenue for the 4th quarter of store 2: 35000
What is the projected annual sales for store 2? 125000

SALES FOR TANDEM AT ALL LOCATIONS

Store: TANDEM @ DeZavala & I10
Manager: Carmen Vasquez
Projected Annual Sales: $100,000.00
Total Quarterly Sales: $112,000.00
Difference: $12,000.00
Performance: KEEP UP THE GOOD WORK! Your store is ahead of your annual sales
projections or right on target.

Store: TANDEM @ 281 & 1604
Manager: Diego Garza
Projected Annual Sales: $125,000.00
Total Quarterly Sales: $118,000.00
Difference: $-7,000.00
Performance: WARNING! Your store sales are below annual projections.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote