|
-
October 25th, 2008, 10:11 PM
#1
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?
-
October 26th, 2008, 03:13 AM
#2
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]
-
October 26th, 2008, 05:52 AM
#3
Re: need program help in cSharp
in your example
Code:
amount = GetAmount();
shippingCharge = DetermineShipCharge(amount);
-
October 26th, 2008, 10:50 AM
#4
Re: need program help in cSharp
thank you, i appreciate it
-
October 27th, 2008, 01:51 AM
#5
Re: need program help in cSharp
if your problem is resolved please mark it as resolved.
thanks.
-
October 27th, 2008, 01:53 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|