Click here to Skip to main content
15,897,371 members
Home / Discussions / C#
   

C#

 
GeneralRe: Effective Security Access Check Pin
Jeffrey Walton28-Dec-07 8:08
Jeffrey Walton28-Dec-07 8:08 
GeneralRe: Effective Security Access Check [modified] Pin
martin_hughes28-Dec-07 9:28
martin_hughes28-Dec-07 9:28 
GeneralI ate too much... and another nice C# 3.0 feature Pin
martin_hughes25-Dec-07 6:17
martin_hughes25-Dec-07 6:17 
GeneralRe: I ate too much... and another nice C# 3.0 feature Pin
Jeffrey Walton25-Dec-07 7:39
Jeffrey Walton25-Dec-07 7:39 
GeneralRe: I ate too much... and another nice C# 3.0 feature Pin
martin_hughes25-Dec-07 7:50
martin_hughes25-Dec-07 7:50 
GeneralRe: I ate too much... and another nice C# 3.0 feature Pin
Waleed Eissa25-Dec-07 17:09
Waleed Eissa25-Dec-07 17:09 
GeneralRe: I ate too much... and another nice C# 3.0 feature Pin
martin_hughes26-Dec-07 2:28
martin_hughes26-Dec-07 2:28 
GeneralExercise Solution Pin
Kefaleas Stavros24-Dec-07 23:52
Kefaleas Stavros24-Dec-07 23:52 
I have met this exercise in a book I am reading :

Develop a C# application that will determine whether any of several department-store customers has exceeded the credit limit on a charge account. For each customer, the following facts are available:

account number

balance at the beginning of the month

total of all items charged by the customer this month

total of all credits applied to the customer's account this month

allowed credit limit.

The application should input all these facts as integers, calculate the new balance (= beginning balance + charges credits), display the new balance and determine whether the new balance exceeds the customer's credit limit. For those customers whose credit limit is exceeded, the application should display the message "Credit limit exceeded". Use sentinel-controlled repetition to obtain the data for each account.


I have tried to code this solution and I came to this source code :

CustomerTest.cs :

using System;<br />
<br />
public class CustomerTest<br />
{<br />
    public static void Main(string[] args)<br />
    {<br />
        //Declarations<br />
        int account_Number;<br />
        int initial_Balance;<br />
        int total_Month_Items;<br />
        int total_Month_Credits;<br />
        int credit_Limit;<br />
        <br />
        <br />
        //create customer object<br />
        Customer myCustomer = new Customer(0, 0, 0, 0, 0);<br />
<br />
<br />
        //take input from the user<br />
        Console.Write("Enter account number or -1 to quit : ");<br />
        account_Number = Convert.ToInt32(Console.ReadLine());<br />
<br />
        //loop until sentinel value read from user<br />
        while (account_Number != -1)<br />
        {<br />
            Console.Write("Enter balance at the beggining of the month : ");<br />
            initial_Balance = Convert.ToInt32(Console.ReadLine());<br />
<br />
            Console.Write("Enter total of all items charged by the customer this month : ");<br />
            total_Month_Items = Convert.ToInt32(Console.ReadLine());<br />
<br />
            Console.Write("Enter total of all credits applied to the customer's account this month : ");<br />
            total_Month_Credits = Convert.ToInt32(Console.ReadLine());<br />
<br />
            Console.Write("Enter customer's credit limit : ");<br />
            credit_Limit = Convert.ToInt32(Console.ReadLine());<br />
<br />
            myCustomer.AccountNumber = account_Number;<br />
            myCustomer.InitialBalance = initial_Balance;<br />
            myCustomer.TotalMonthItems = total_Month_Items;<br />
            myCustomer.TotalMonthCredit = total_Month_Credits;<br />
            myCustomer.CreditLimit = credit_Limit;<br />
<br />
            //call DetermineNewBalance methd<br />
            myCustomer.DetermineNewBalance();<br />
<br />
        }<br />
    }<br />
}



Customer.cs :

using System;<br />
<br />
public class CustomerTest<br />
{<br />
    public static void Main(string[] args)<br />
    {<br />
        //Declarations<br />
        int account_Number;<br />
        int initial_Balance;<br />
        int total_Month_Items;<br />
        int total_Month_Credits;<br />
        int credit_Limit;<br />
        <br />
        <br />
        //create customer object<br />
        Customer myCustomer = new Customer(0, 0, 0, 0, 0);<br />
<br />
<br />
        //take input from the user<br />
        Console.Write("Enter account number or -1 to quit : ");<br />
        account_Number = Convert.ToInt32(Console.ReadLine());<br />
<br />
        //loop until sentinel value read from user<br />
        while (account_Number != -1)<br />
        {<br />
            Console.Write("Enter balance at the beggining of the month : ");<br />
            initial_Balance = Convert.ToInt32(Console.ReadLine());<br />
<br />
            Console.Write("Enter total of all items charged by the customer this month : ");<br />
            total_Month_Items = Convert.ToInt32(Console.ReadLine());<br />
<br />
            Console.Write("Enter total of all credits applied to the customer's account this month : ");<br />
            total_Month_Credits = Convert.ToInt32(Console.ReadLine());<br />
<br />
            Console.Write("Enter customer's credit limit : ");<br />
            credit_Limit = Convert.ToInt32(Console.ReadLine());<br />
<br />
            myCustomer.AccountNumber = account_Number;<br />
            myCustomer.InitialBalance = initial_Balance;<br />
            myCustomer.TotalMonthItems = total_Month_Items;<br />
            myCustomer.TotalMonthCredit = total_Month_Credits;<br />
            myCustomer.CreditLimit = credit_Limit;<br />
<br />
            //call DetermineNewBalance methd<br />
            myCustomer.DetermineNewBalance();<br />
<br />
        }<br />
    }<br />
}



The problem is in the first file when I use the sentinel-controlled repetition because I get no account number question at the second loop.Any ideas how to fix this one?Thnx!
GeneralRe: Exercise Solution Pin
Luc Pattyn25-Dec-07 0:58
sitebuilderLuc Pattyn25-Dec-07 0:58 
GeneralA simple paint program-C# Pin
Ali Rahimei24-Dec-07 22:48
Ali Rahimei24-Dec-07 22:48 
GeneralRe: A simple paint program-C# Pin
Luc Pattyn25-Dec-07 1:00
sitebuilderLuc Pattyn25-Dec-07 1:00 
GeneralRe: A simple paint program-C# Pin
Paul Conrad25-Dec-07 10:33
professionalPaul Conrad25-Dec-07 10:33 
GeneralA simple paint program-C# Pin
Ali Rahimei24-Dec-07 22:46
Ali Rahimei24-Dec-07 22:46 
GeneralRe: A simple paint program-C# Pin
Giorgi Dalakishvili24-Dec-07 23:03
mentorGiorgi Dalakishvili24-Dec-07 23:03 
QuestionHow i can user User Control in my own Form Pin
wasimsharp24-Dec-07 21:23
wasimsharp24-Dec-07 21:23 
AnswerRe: How i can user User Control in my own Form Pin
Xmen Real 25-Dec-07 2:53
professional Xmen Real 25-Dec-07 2:53 
GeneralRe: How i can user User Control in my own Form Pin
wasimsharp25-Dec-07 19:33
wasimsharp25-Dec-07 19:33 
GeneralRe: How i can user User Control in my own Form Pin
Xmen Real 26-Dec-07 0:40
professional Xmen Real 26-Dec-07 0:40 
GeneralPrint Screen Pin
half-life24-Dec-07 20:19
half-life24-Dec-07 20:19 
GeneralRe: Print Screen Pin
Giorgi Dalakishvili24-Dec-07 20:24
mentorGiorgi Dalakishvili24-Dec-07 20:24 
GeneralSystem.ArgumentException Assistance Needed... [modified] Pin
new_phoenix24-Dec-07 13:38
new_phoenix24-Dec-07 13:38 
QuestionExcel to XML converter with VC# [modified] Pin
iyepb024-Dec-07 10:03
iyepb024-Dec-07 10:03 
GeneralRe: Excel to XML converter with VC# Pin
Ed.Poore25-Dec-07 14:35
Ed.Poore25-Dec-07 14:35 
GeneralRe: Excel to XML converter with VC# Pin
Waleed Eissa25-Dec-07 17:52
Waleed Eissa25-Dec-07 17:52 
GeneralRe: Excel to XML converter with VC# Pin
yonision8-Jan-10 12:58
yonision8-Jan-10 12:58 

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.