Below is a sample implementation of StoreSalesBarChart package assignment5; import java.io.FileNotFoundException; /** * StoreSalesBarChart * @author JunS * */ public class StoreSalesBarChart { String storeName; double storeSales; /** * StoreSalesBarChart constructor * @param sName */ public StoreSalesBarChart(String sName) { storeName = sName; storeSales = 0; } /** * addStoreSales * @param txn */ public void addStoreSales(double txn) { storeSales += txn; } /** * getStoreSales * @return */ public double getStoreSales() { return storeSales; } public void displayBarChart() { System.out.print(storeName + ": "); for (int i=0; i

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

can you please make so i can copy and past it and if you have to use a form can you use java.util.scanner form. thx.

Below is a sample implementation of StoreSalesBarChart

package assignment5; import java.io.FileNotFoundException; /** * StoreSalesBarChart * @author JunS * */ public class StoreSalesBarChart { String storeName; double storeSales; /** * StoreSalesBarChart constructor * @param sName */ public StoreSalesBarChart(String sName) { storeName = sName; storeSales = 0; } /** * addStoreSales * @param txn */ public void addStoreSales(double txn) { storeSales += txn; } /** * getStoreSales * @return */ public double getStoreSales() { return storeSales; } public void displayBarChart() { System.out.print(storeName + ": "); for (int i=0; i<storeSales/100; i++) { System.out.print("*"); } System.out.println(""); } public String getBarChartString() { String barChartString = storeName + ": "; for (int i=0; i<storeSales/100; i++) { barChartString += "*"; } return barChartString; } public String getBarChartString(String sign) { String barChartString = storeName + ": "; for (int i=0; i<storeSales/100; i++) { barChartString += sign; } return barChartString; } /** * main() * @param args */ public static void main(String[] args) { StoreSalesBarChart bc1 = new StoreSalesBarChart("Store 1"); bc1.addStoreSales(300); bc1.addStoreSales(900); StoreSalesBarChart bc2 = new StoreSalesBarChart("Store 2"); bc2.addStoreSales(300); bc2.addStoreSales(500); StoreSalesBarChart bc3 = new StoreSalesBarChart("Store 3"); bc3.addStoreSales(1300); bc3.addStoreSales(500); //bc1.displayBarChart(); //bc2.displayBarChart(); //bc3.displayBarChart(); System.out.println(bc1.getBarChartString()); System.out.println(bc2.getBarChartString("=")); System.out.println(bc3.getBarChartString("+")); } }

Make a modification that when receiving a store name, make it 20 char. If the incoming name is longer than 20, truncate. If the incoming name is shorter than 20, append spaces to make it 20.

--- Skill check: String length and loop.

--- Note: Don't use String.repeat or formatted printing. You must use concatenation inside a loop.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
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