Click here to Skip to main content
16,011,120 members
Home / Discussions / C#
   

C#

 
Questionxml File name error [modified] Pin
7111-Apr-07 21:04
7111-Apr-07 21:04 
AnswerRe: xml File name error Pin
Jaiprakash M Bankolli11-Apr-07 21:29
Jaiprakash M Bankolli11-Apr-07 21:29 
GeneralRe: xml File name error Pin
7111-Apr-07 22:37
7111-Apr-07 22:37 
GeneralRe: xml File name error Pin
Jaiprakash M Bankolli12-Apr-07 0:23
Jaiprakash M Bankolli12-Apr-07 0:23 
GeneralRe: xml File name error Pin
7112-Apr-07 0:38
7112-Apr-07 0:38 
QuestionAdding user defined compiler Error Pin
SakthiSurya11-Apr-07 20:13
SakthiSurya11-Apr-07 20:13 
AnswerRe: Adding user defined compiler Error Pin
Jaiprakash M Bankolli12-Apr-07 0:41
Jaiprakash M Bankolli12-Apr-07 0:41 
QuestionSentinel Loop Question Pin
JMOdom11-Apr-07 19:20
JMOdom11-Apr-07 19:20 
I am newbie at this, please try to be patient with me. Smile | :) In my class at school we have been trying out various loops in problems. The instructor calls the one we've been using a "Sentinel Loop". If there is another name for it I don't know what it is. Frown | :(

D'Oh! | :doh: I can get it to accept the input and also the stopping statement. I can even get the program to tell me the sales tax and shipping "on an individual input".

The instructor wants to be able to input several figures and when the stopping statement is triggered, have the program show the total shipping cost and sales tax for all of the inputs together.

I have placed the math parts between the two input statements, and also outside of the loop.

My question is: "Do I need to put the math section into a method and if so where would I place the calling statement so that it would only work after the stop statement is triggered or would something else be even more appropriate?" Sigh | :sigh:

I have been beating my head against the wall for the last 10 days, and have not figured out an answer. I have tried everything I can think of. Dead | X|

Can someone either please answer the question or at least steer me to the information on how to do this type of a problem. I would appreciate it greatly.

This is the main body of my sentinel loop program. I can get it to work fine.

using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace Exer4Chpt6<br />
{<br />
    class Program<br />
    {<br />
        static void Main()<br />
        {<br />
            string inValue = "";<br />
            double salesAmount = 0;<br />
            double salesTax;<br />
            double shipAmount = 0;<br />
            double grdTotal;<br />
            const double INTEREST_RATE = .07;<br />
            double overAllTotal = 0;<br />
            double totalShippingAmt = 0;<br />
            double totalSalesTax = 0;<br />
<br />
            Console.WriteLine("Enter as many different sales amounts ");<br />
            Console.WriteLine("as you want. You will be shown the sales ");<br />
            Console.WriteLine("amount, sales tax, shipping amount, and ");<br />
            Console.WriteLine("the grand total. To Stop, enter");<br />
            Console.WriteLine(" -99");<br />
            Console.WriteLine();<br />
<br />
            Console.WriteLine("Please type in a sales amount.");<br />
            inValue = Console.ReadLine(); // Priming read, input before loop<br />
            while (inValue != "-99")<br />
            {<br />
              salesAmount = Convert.ToDouble(inValue);<br />
              salesTax = salesAmount * INTEREST_RATE;<br />
<br />
                Console.WriteLine("Please type in a sales amount.");<br />
                inValue = Console.ReadLine(); // reassigns data in inValue to check in loop<br />
            }<br />
        }<br />
    }<br />
}<br />

This is the math section of my program that I'm having the trouble with. The problem isn't in the math expressions themselves, but more in the placement to get it to do what I want.

if (salesAmount < 250.01)<br />
{<br />
 shipAmount = 5.0;<br />
}<br />
else if (salesAmount < 500.01)<br />
{<br />
 shipAmount = 8.0;<br />
}<br />
else if (salesAmount < 1000.01)<br />
{<br />
 shipAmount = 10.0;<br />
}<br />
else if (salesAmount <= 5000.00)<br />
{<br />
 shipAmount = 15.0;<br />
}<br />
else if (salesAmount > 5000.00)<br />
{<br />
 shipAmount = 20.0;<br />
}<br />
else<br />
  Console.WriteLine("Please type in a sales amount.");<br />
<br />
                grdTotal = salesAmount + shipAmount + salesTax;<br />
                overAllTotal += grdTotal;<br />
                totalShippingAmt += shipAmount;<br />
                totalSalesTax += salesAmount;<br />
Console.WriteLine();<br />
Console.WriteLine("Your final sales amount was: {0:C2}", grdTotal);<br />
Console.WriteLine();<br />
Console.WriteLine("Your sales tax amount was: {0:C2}", totalSalesTax);<br />
Console.WriteLine();<br />
Console.WriteLine("Your shipping amount was: {0:C2}", totalShippingAmt);<br />
Console.WriteLine();<br />
Console.WriteLine("Your total bill is: {0:C2} ", overAllTotal);<br />
Console.WriteLine();


Any help will be very greatly welcome. Thank you. Big Grin | :-D
AnswerRe: Sentinel Loop Question Pin
JMOdom12-Apr-07 5:19
JMOdom12-Apr-07 5:19 
QuestionWhy Main? Pin
Saranya B11-Apr-07 19:19
Saranya B11-Apr-07 19:19 
AnswerRe: Why Main? Pin
CPallini11-Apr-07 20:49
mveCPallini11-Apr-07 20:49 
AnswerRe: Why Main? Pin
kkun11-Apr-07 21:25
kkun11-Apr-07 21:25 
AnswerRe: Why Main? Pin
Jaiprakash M Bankolli11-Apr-07 21:45
Jaiprakash M Bankolli11-Apr-07 21:45 
AnswerRe: Why Main? Pin
Guffa11-Apr-07 22:31
Guffa11-Apr-07 22:31 
QuestionRichTextBox flickering Pin
moid.ahmed11-Apr-07 19:16
moid.ahmed11-Apr-07 19:16 
AnswerRe: RichTextBox flickering Pin
andre_swnpl11-Apr-07 19:29
andre_swnpl11-Apr-07 19:29 
QuestionEvaluvating Expression in C# Pin
act_ramesh11-Apr-07 18:53
act_ramesh11-Apr-07 18:53 
AnswerRe: Evaluvating Expression in C# Pin
Stevo Z11-Apr-07 22:28
Stevo Z11-Apr-07 22:28 
QuestionWhy didn't I get the job? Pin
Mark J. Miller11-Apr-07 12:04
Mark J. Miller11-Apr-07 12:04 
AnswerRe: Why didn't I get the job? Pin
J$11-Apr-07 12:47
J$11-Apr-07 12:47 
GeneralRe: Why didn't I get the job? Pin
Mark J. Miller11-Apr-07 13:01
Mark J. Miller11-Apr-07 13:01 
GeneralRe: Why didn't I get the job? Pin
J$11-Apr-07 13:38
J$11-Apr-07 13:38 
GeneralRe: Why didn't I get the job? Pin
Mark J. Miller11-Apr-07 13:45
Mark J. Miller11-Apr-07 13:45 
AnswerRe: Why didn't I get the job? Pin
Colin Angus Mackay11-Apr-07 12:49
Colin Angus Mackay11-Apr-07 12:49 
GeneralRe: Why didn't I get the job? Pin
Mark J. Miller11-Apr-07 13:16
Mark J. Miller11-Apr-07 13:16 

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.