CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2008
    Posts
    9

    need program help in cSharp

    THE CODE:

    using System;

    namespace ProgramOne
    {
    class ProgramOne
    {
    static void Main()
    {
    //Declare variables
    double amount, shippingCharge;

    //Get the purchase total, calculate shipping charges, and display results
    amount = GetAmount();
    shippingCharge = DetermineShipCharge();
    DisplayResults(amount, shippingCharge);
    }

    static double GetAmount()
    {
    //Declare variables
    double purchaseTotal;

    //Get the amount, parse it, and return it
    Console.Write("Please enter the purchase total: ");
    purchaseTotal = double.Parse(Console.ReadLine());

    //Return the parsed value
    return purchaseTotal;
    }

    static double DetermineShipCharge(double amount)
    {
    //Declare variables
    double shippingCharge;

    //Determine shipping charge
    if (amount <= 250.00)
    shippingCharge = 5.00;
    else if (amount >= 250.01)
    shippingCharge = 8.00;
    else if (amount >= 500.01)
    shippingCharge = 10.00;
    else if (amount >= 1000.01)
    shippingCharge = 15.00;
    else if (amount <= 5000.00)
    shippingCharge = 15.00;
    else
    shippingCharge = 20.00;

    //Return shipping charge
    return shippingCharge;
    }

    static void DisplayResults(double amount, double shippingCharge)
    {
    Console.WriteLine("Purchasing {0:C} worth of merchandise results in {1:C} worth of shipping charges.", amount, shippingCharge);
    }
    }
    }


    ----------------------
    first off: the program is supposed to ask for a purchase total then depending on the purchase total amount determine shipping charges then display the shipping charges.

    For some reason, in the Main class, in the line "shippingCharge = DetermineShipCharge();", "DetermineShipCharge();" has a blue jagged line under it.. has an error: No overload for method 'DetermineShipCharge' takes '0' arguments
    i cant for the life of me figure out whats wrong much less how to correct it. any ideas?

  2. #2
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Lightbulb Re: need program help in cSharp

    look, here is the declaration of your method:

    Code:
    static double DetermineShipCharge(double amount)
    so it is mandatory to pass a double value to this method when you call it.

    Code:
    double x = 10;
    DetermineShipCharge(x);
    Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]

  3. #3
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: need program help in cSharp

    in your example
    Code:
    amount = GetAmount();
    shippingCharge = DetermineShipCharge(amount);

  4. #4
    Join Date
    Oct 2008
    Posts
    9

    Re: need program help in cSharp

    thank you, i appreciate it

  5. #5
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Resolved Re: need program help in cSharp

    if your problem is resolved please mark it as resolved.
    thanks.

  6. #6
    Join Date
    Mar 2008
    Location
    IRAN
    Posts
    811

    Re: need program help in cSharp

    also please rate the posts.
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured