Need help with this.
Write a program that asks the user to enter today's sales for five stores. The program should then display a bar graph comparing each store's sales. Create each bar in the bar graph displaying a row of asterisks. Each asterisks should represent $100 of sales.

Her is an example of the program's output.

Enter today's sales for store 1: 1000 [Enter]
Enter today's sales for store 2: 1200 [Enter]
Enter today's sales for store 3: 1800 [Enter]
Enter today's sales for store 4: 800 [Enter]
Enter today's sales for store 5: 1900 [Enter]

SALES BAR CHART
(Each * = $100)
Store 1: **********
Store 2: ************
Store 3: ******************
Store 4: ********
Store 5: *******************

Recommended Answers

All 6 Replies

Member Avatar for Unhnd_Exception

This is the second time I've seen this homework assignment.

You need to floor the sales / 100 and create a string of asterisks with that many.

example

Dim Sales As Integer = 1800
Dim Asterisks As Integer = CInt(Math.Floor(Sales / 100))
Dim RowGraph As New String("*"c, Asterisks)

Don't forget to: Mark your thread as solved

thanks for the reply, but I wanted to get five stores sales data from the user and display chart in a list box

Here is what I started but don't know how to do the do while part for numeric value check

Dim strAsterisks As String = "*" ' asterisks 

Dim strAsterisks1 As String 
Dim strAsterisks2 As String 
Dim strAsterisks3 As String 
Dim strAsterisks4 As String 
Dim strAsterisks5 As String 
' Holds Asterisks for each store 

Dim strStore1, strStore2, strStore3, strStore4, strStore5 As String ' Holds Store data 

Dim intAsterisks1, intAsterisks2, intAsterisks3, intAsterisks4, intAsterisks5 As Integer 'Number of Asterisks to be put in strAsterisks 


' The following loop gets the sales for each store. 
strStore1 = InputBox("Enter the sales for Store 1", "Sales Amount Needed", "100") ..
.
.
.
.
.
.
.
.
strStore1 = "Store 1:" & strAsterisks1 
strStore2 = "Store 2:" & strAsterisks2 
strStore3 = "Store 3:" & strAsterisks3 
strStore4 = "Store 4:" & strAsterisks4 
strStore5 = "Store 5:" & strAsterisks5 
' results are shown in lstOutput 
lstOutput.Items.Add(strStore1) 
lstOutput.Items.Add(strStore2) 
lstOutput.Items.Add(strStore3) 
lstOutput.Items.Add(strStore4) 
lstOutput.Items.Add(strStore5)

thanks for the help, lab done, almost,

I wanted to know what function is this,

Dim RowGraph As New String("*"c, Asterisks)

I had been searching this amazing function but couldn't find its more use and examples.

Member Avatar for Unhnd_Exception

Its not a function its a constructor.

You know you can initialize a string with Dim S as String = "S" . You can also intialize a string with the New keyword in 8 other ways. One of which is with how many of the same character like above.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.