Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
QuestionTrying to make a converter Pin
daddy35615-Feb-14 14:01
daddy35615-Feb-14 14:01 
AnswerRe: Trying to make a converter Pin
Richard Andrew x6415-Feb-14 17:26
professionalRichard Andrew x6415-Feb-14 17:26 
GeneralRe: Trying to make a converter Pin
Mycroft Holmes15-Feb-14 20:41
professionalMycroft Holmes15-Feb-14 20:41 
GeneralRe: Trying to make a converter Pin
harold aptroot15-Feb-14 23:52
harold aptroot15-Feb-14 23:52 
GeneralRe: Trying to make a converter Pin
harold aptroot15-Feb-14 23:50
harold aptroot15-Feb-14 23:50 
GeneralRe: Trying to make a converter Pin
daddy35617-Feb-14 11:49
daddy35617-Feb-14 11:49 
GeneralRe: Trying to make a converter Pin
harold aptroot17-Feb-14 21:30
harold aptroot17-Feb-14 21:30 
GeneralRe: Trying to make a converter Pin
daddy35618-Feb-14 0:27
daddy35618-Feb-14 0:27 
GeneralRe: Trying to make a converter Pin
harold aptroot18-Feb-14 0:42
harold aptroot18-Feb-14 0:42 
GeneralRe: Trying to make a converter Pin
daddy35618-Feb-14 4:03
daddy35618-Feb-14 4:03 
GeneralRe: Trying to make a converter Pin
harold aptroot18-Feb-14 4:37
harold aptroot18-Feb-14 4:37 
GeneralRe: Trying to make a converter Pin
daddy35618-Feb-14 6:06
daddy35618-Feb-14 6:06 
GeneralRe: Trying to make a converter Pin
harold aptroot18-Feb-14 6:25
harold aptroot18-Feb-14 6:25 
GeneralRe: Trying to make a converter Pin
harold aptroot18-Feb-14 10:12
harold aptroot18-Feb-14 10:12 
GeneralRe: Trying to make a converter Pin
daddy35618-Feb-14 10:48
daddy35618-Feb-14 10:48 
GeneralRe: Trying to make a converter Pin
harold aptroot18-Feb-14 22:09
harold aptroot18-Feb-14 22:09 
GeneralRe: Trying to make a converter Pin
daddy35619-Feb-14 3:38
daddy35619-Feb-14 3:38 
GeneralRe: Trying to make a converter Pin
harold aptroot19-Feb-14 4:34
harold aptroot19-Feb-14 4:34 
GeneralRe: Trying to make a converter Pin
daddy35619-Feb-14 5:35
daddy35619-Feb-14 5:35 
QuestionC# string formatting Pin
Member 1059957015-Feb-14 13:47
Member 1059957015-Feb-14 13:47 
I have this code so far, and am having issues with lining up the information output correctly. I'm not sure what I'm doing wrong at the moment. It's mainly the bold section that I can't get to output correctly

It is supposed to look like

C#
Price    .10      .15      .20      .25
--------------------------------------
10.00    1.00    1.50     2.00     2.25
15.00    1.50    2.25     3.00     3.25
20.00    2.00    3.00     4.00     5.00
25.00    2.50    3.75     5.00     6.25



But it looks like

C#
.10   .15   .20   .25
10.00 15.00 20.00 25.00
1.00   1.50   2.00   2.25   1.50  2.25   3.00   3.25 etc.



C#
namespace TippingTable2GUI
{
public partial class frmMain : Form
{
    public frmMain()
    {
        InitializeComponent();
    }

    private void buttonCalc_Click(object sender, EventArgs e)
    {

        double dinnerPrice = Convert.ToDouble(minPrice.Text);
        double tipRate;
        double tip;

        double maxRate = Convert.ToDouble(maxTax.Text);
        double lowRate = Convert.ToDouble(minTax.Text);
        double minDinner = Convert.ToDouble(minPrice.Text);
        double maxDinner = Convert.ToDouble(maxPrice.Text);

        const double TIPSTEP = 0.05;

        const double DINNERSTEP = 10.00;


        tipRate = lowRate;


        label1.Text = "";
        label6.Text = "";
        label7.Text = "";

        for (tipRate = lowRate; tipRate <= maxRate; tipRate += TIPSTEP)
            label1.Text = label1.Text + String.Format(" {0, 8}", tipRate.ToString("F"));
        label1.Text = label1.Text + String.Format("{0, 8}", tipRate.ToString("C"));
        const int NUM_DASHES = 50;
        for (int x = 0; x < NUM_DASHES; ++x) ;


        while (dinnerPrice <= maxDinner)
        {
            label6.Text = label6.Text + String.Format("{0, 8}", dinnerPrice.ToString("C"));
            while (tipRate <= maxRate)
            {
                tip = dinnerPrice * tipRate;
                label7.Text = label7.Text + String.Format("{0, 8}", tip.ToString("F"));
                tipRate += 0.05;
            }
            dinnerPrice += DINNERSTEP;
            tipRate = lowRate;

        }


    }
}

AnswerRe: C# string formatting Pin
Mycroft Holmes15-Feb-14 17:07
professionalMycroft Holmes15-Feb-14 17:07 
AnswerRe: C# string formatting Pin
OriginalGriff15-Feb-14 23:06
mveOriginalGriff15-Feb-14 23:06 
AnswerRe: C# string formatting Pin
V.16-Feb-14 21:05
professionalV.16-Feb-14 21:05 
QuestionClick Event On DataGridview Cell Pin
Soahib jamil15-Feb-14 1:36
Soahib jamil15-Feb-14 1:36 
AnswerRe: Click Event On DataGridview Cell Pin
Richard MacCutchan15-Feb-14 1:41
mveRichard MacCutchan15-Feb-14 1:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.