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

Write a program that uses ifstream to receive data for today\'s sales for five s

ID: 674357 • Letter: W

Question

Write a program that uses ifstream to receive data for today's sales for five stores from a text file. The input file should contain the name of each store (choosen by you) and the sales amount for today. Here is an example of the input file (please choose your own store names and amounts).

Macy's 1000

Nordstrom 12000

Boscov's 1800

Dillard's 800

JCPenney 1900

The program should then print to a file (output.out) a bar graph comparing each stores sales. Create each band in the bar graph by displaying a row of asterisks. Each asterisk should represent $100 of sales.

Here is an example of the program's output.

SALES BAR CHART

(each * = $100)

Store 1 : * * * * * * * * * * ( Macy's)

Store 2 : * * * * * * * * * * * * (Nordstrom)

Store 3: * * * * * * * * * * * * * * * * * * ( Boscovs)

Store 4: * * * * * * * * ( Dillard's)

Store 5 : * * * * * * * * * * ( JCPenney)

Explanation / Answer

import java.util.Scanner; import java.io.*; public class BarChart { public static void main(String[] args) throws IOException { int store1,store2,store3,store4,store5; int bar1,bar2,bar3,bar4,bar5; Scanner inputFile = new Scanner(System.in); File inputFile = new File("sales.txt"); File outputFile = new File("storeReport.txt"); PrintWriter outputFile = new PrintWriter("storeReport.txt"); outputFile.println("SALES BAR CHART "); bar1 = store1/100; outputFile.println("store 1 : "); for(int i = 1; i
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