Write a method named CustomerCreditLimit() that
accepts a double as a parameter and displays the value
as the amount of credit granted to a customer. Provide a
default value for the method so that if a program calls the
method without using an argument, the credit limit displays
$500. Write a console-based program with a Main()
method that proves the credit limit method works correctly
whether it is called with an argument or not. Save
the file as Credit.cs.
I am Lost! could anyone help
`

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            double balance = 0.00;
            double creditLimit = 500;
            CustomerCreditLimit(balance, creditLimit);
            Console.ReadLine();
        }
        public static double CustomerCreditLimit(double balance, double creditLimit)
        {


            //get and process input
            Console.Write("Enter the customer current balance: ");
            balance = Convert.ToDouble(Console.ReadLine());
            if (balance <= 500)
            {
                Console.Write("{0:c} the amount of credit granted to a customer", balance);
            }

            if (balance > creditLimit) //test for overlimit
            {
                Console.WriteLine("{0:c} Credit limit exceeded!", balance);
            }

            return balance;
        }

    }
}

`

Recommended Answers

All 3 Replies

What are you lost with? Sorry but we need you to be a bit more specific.

You should be more specific in your questioning, as Ketsuekiame already pointed out.
I'm inferring it could have something to do with method overloading

I think perhaps you've misunderstood the assignment. Here's some revised code that should make it clearer:

    static void Main(string[] args)
    {
        double balance = 0.00;
        Console.WriteLine("Current credit limit is : " + CustomerCreditLimit().ToString());
        Console.Write("Enter the customer current balance: ");
        balance = Convert.ToDouble(Console.ReadLine()); 
        Console.WriteLine("The credit limit for this balancxe is : " + CustomerCreditLimit(balance).ToString());
        Console.ReadLine();
    }
    public static double CustomerCreditLimit(double balance = 500)
    {
        double newcreditlimit = 500;
        if(balance > 500)
            newcreditlimit = balance;
        return newcreditlimit;
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.