4 Replies - 523 Views - Last Post: 14 February 2013 - 08:32 AM Rate Topic: -----

#1 braddey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 20-September 12

Creating a program to display percentages "receiving wrong output&

Posted 05 October 2012 - 01:51 PM

Hello, dreamincode community, I'm creating a program to find 5-10 percent of $10-15 dollars. So far I've been receiving an output not even remotely close to what it should be. One other small error but 10-15 should be displayed with a $ sign,which I have been unable to get to display thus far. I'll post up the pseudo-code and a screenshot of how it should look and how my display box looks. thanks for your time,braddey.

Public Class frmMain

    Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
       
        Dim Discounts As Integer


        Decimal.TryParse(txtDiscounts.Text, Discounts)



        For intTerm As Integer = 10 To 15
            txtDiscounts.Text = txtDiscounts.Text &
                "Sales Amt:" & intTerm & ControlChars.NewLine
            For disrate As Decimal = 0.05 To 0.1 Step 0.01
                Discounts = (intTerm / disrate)
                txtDiscounts.Text = txtDiscounts.Text &
                disrate.ToString("P0") & ":" &
                Discounts.ToString("C2") & ControlChars.NewLine
            Next disrate
            txtDiscounts.Text = txtDiscounts.Text & ControlChars.NewLine

        Next intTerm






    End Sub

    
End Class



how mine looks
Posted Image

how it should look
Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a program to display percentages "receiving wrong output&

#2 braddey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 20-September 12

Re: Creating a program to display percentages "receiving wrong output&

Posted 05 October 2012 - 01:58 PM

figured out why the Dollar sign isn't displaying, it was missing from the " "Sales Amt:" & intTerm & ControlChars.NewLine"
Was This Post Helpful? 0
  • +
  • -

#3 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Creating a program to display percentages "receiving wrong output&

Posted 05 October 2012 - 02:36 PM

Ask yourself one question...

How much is 10 / .05 ?
Was This Post Helpful? 0
  • +
  • -

#4 braddey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 20-September 12

Re: Creating a program to display percentages "receiving wrong output&

Posted 05 October 2012 - 03:15 PM

*facepalm, good point I feel like an idiot now. Makes perfect sense why I'm receiving all that output now. Thank you never the less.
Was This Post Helpful? 0
  • +
  • -

#5 reveal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 14-February 13

Re: Creating a program to display percentages "receiving wrong output&

Posted 14 February 2013 - 08:32 AM

View Postlar3ry, on 05 October 2012 - 02:36 PM, said:

Ask yourself one question...

How much is 10 / .05 ?



They have two problems.

Dim Discounts As Integer Should be Dim Discounts As Decimal
Discounts = (intTerm / disrate) Should be Discounts = intTerm * disrate

I know this is an old thread, but I as well just started my programming class and had the same problem as the original poster.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1