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

write a program that asks the users to enter today\'s sales forfive store. the p

ID: 3609492 • Letter: W

Question

write a program that asks the users to enter today's sales forfive store. the program should display a bar chart comparing each store'ssales. Creat each bar in the bar chart by displaying a row ofasterisks. Each asterisk should represent $100 of sales. Here is an example of the program's output: Enter today's sales for store1: 1000[Enter] Enter today's sales for store1: 1200[Enter] Enter today's sales for store1: 1800[Enter] Enter today's sales for store1: 800[Enter] Enter today's sales for store1: 1900[Enter] Sales bar chart Store1: ********** Store2: ************ Store3: ****************** Store4: ******** Store5: ******************* write a program that asks the users to enter today's sales forfive store. the program should display a bar chart comparing each store'ssales. Creat each bar in the bar chart by displaying a row ofasterisks. Each asterisk should represent $100 of sales. Here is an example of the program's output: Enter today's sales for store1: 1000[Enter] Enter today's sales for store1: 1200[Enter] Enter today's sales for store1: 1200[Enter] Enter today's sales for store1: 1800[Enter] Enter today's sales for store1: 1800[Enter] Enter today's sales for store1: 800[Enter] Enter today's sales for store1: 800[Enter] Enter today's sales for store1: 1900[Enter] Sales bar chart Store1: ********** Store2: ************ Store3: ****************** Store4: ******** Store5: ******************* Enter today's sales for store1: 1900[Enter] Sales bar chart Store1: ********** Store2: ************ Store3: ****************** Store4: ******** Store5: *******************

Explanation / Answer

import java.util.*;
import java.io.*;
public class BarChartonly
{public static void main(String[] args)
{int i;
int stores=5;
int total[]=new int[stores];
Scanner key=new Scanner(System.in);
for(i=0;i<stores;i++)
   {System.out.print("Enter today's sales forstore"+(i+1)+": ");
    total[i]=key.nextInt();
}
graph(total,stores);
}


public static void graph(int total[],int stores)
{int i,j,tot;
for(i=1;i<stores;i++)
   {System.out.print("Store"+i+": ");
tot=total[i]/100;
    for(j=0;j<tot;j++)
       System.out.print("*");
    System.out.println("");
    }    
return;
}
}