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

Write a program to do the following: Ask the user to enter the total sales for a

ID: 3862089 • Letter: W

Question

Write a program to do the following: Ask the user to enter the total sales for a chain of stores that you own. The number of stores will vary for each user input Display the total sales in a bar graph for each store. The graph should use asterisks with each asterisk representing $100 of a sale. Input Validation: The input must be evenly divisible by 100 Requirements: The output must match exactly mine. The graphs must be dynamically generated based on the user input. You must use for loops to solve the problem you are NOT allowed to use arrays.

Explanation / Answer

import java.util.Scanner;


public class StoreSalesBarGraph {

   public static void main(String[] args) {
       Scanner userInput = new Scanner(System.in);
       System.out.print("How many stores are there?:");
       int numStores = userInput.nextInt();
       double[] store = new double[numStores];
      
       for(int i = 0; i < numStores; i++)
       {
           System.out.print("Enter the total sales for Store " + (i + 1) + ":");
           store[i] = userInput.nextDouble();
           if (store[i] % 100 != 0){
               System.out.println("Please enter the multiples of 100");
               break;
           }
       }
      
       System.out.print(" GRAPH OF TOTAL SALES");
       System.out.print(" " + "(Each * = $100) ");
      
       for(int i = 0; i < numStores; i++)
       {
           System.out.print("Store " + (i + 1) + ":");
          
           for(int c = 0; c < store[i]/100; c++)
               System.out.print("*");
          
           System.out.println();
       }
      
       userInput.close();

   }

}

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