本文介绍了为什么这个表不能正确执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是整个代码,应该列出价格这个词,然后是小费率。这个词应该在哪里,但它没有把小费率放在...任何建议?

This is the entire code that is supposed to list the word 'Price" followed by tip rates. The word is where it should be but it doesn't put the tip rates in ...any suggestions?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TippingTable.cs
{
    class Program
    {
        static void Main(string[] args)
        {
            double dinnerPrice = 10.00;
            double tipRate;
            double tip;
            const double LOWRATE = 0.10;
            const double MAXRATE = 0.25;
            const double TIPSTEP = 0.05;
            const double MAXDINNER = 100.00;
            const double DINNERSTEP = 10.00;


            Console.Write("   Price");
            for(tipRate = LOWRATE; tipRate <= MAXRATE; tipRate +=
                TIPSTEP)
            Console.Write("{0, 8}", tipRate.ToString("F"));
            Console.WriteLine ();
            Console.WriteLine("-----------------------------------------");

            tipRate = LOWRATE;
            while (dinnerPrice <= MAXDINNER)
            {
                Console.Write("{0, 8}", dinnerPrice.ToString("C"));
                while (tipRate <= MAXRATE)
                {
                    tip = dinnerPrice * tipRate;
                    Console.Write("{0, 8}", tip.ToString("F"));
                    tipRate += 0.05;
                }
                dinnerPrice += DINNERSTEP;
                tipRate = LOWRATE;
                Console.WriteLine ();
            }
        }








        }
    }

推荐答案

Console.Write("   Price");

并在调试器中运行您的应用。

当它达到您设置的断点时,它将停止并等待您告诉它该做什么。

现在您可以查看变量及其内容,单步执行程序并完全遵循它的内容做什么和为什么。



听起来可能很复杂,但它真的非常简单(或者无论如何都是调试的基础),这是一项非常值得开发的技能!

And run your app in the debugger.
When it hits the breakpoint you set, it will stop and wait for you to tell it what to do.
Now you can look at variables and their content, single step your program and follow exactly what it is doing and why.

It may sound complicated, but it's really very simple (or the basics of debugging are, anyway) and it's a skill that is well worth developing!



这篇关于为什么这个表不能正确执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 04:37