any body could help/show me a c# prog on how this one should be done :
amount ex: 50
amount changes per 3min of calls,
when, call reaches 4mins, amount becomes 100. ( start to 3min = 50)
when, call reaches 7min, amount becomes 150. ( 3.1 to 6 = 100)
and so on ...
minutes must be based on user input ..
someone help, sorry if my english is bad :)
7 replies to this topic
#1
Posted 28 August 2010 - 02:39 AM
|
|
|
#2
Posted 01 September 2010 - 08:04 AM
#3
Posted 06 September 2010 - 05:09 PM
Console.WriteLine("Enter Call Duration: ");
double CallDuration = double.Parse(Console.ReadLine());
string rate = (string.Format("{0:N2}", ((50 / 3) * CallDuration)));
double payment = Convert.ToDouble(rate);
Console.Write(payment);
since I can only divide 50 by 3 to get the equivalent rate for each minute, and decimal places must not be rounded off
but 1 minute already is 50 as well as 2 and 3.
4 5 and 6 will be 100
7 8 9 will be 150
and so on,
can't find a way for this..
double CallDuration = double.Parse(Console.ReadLine());
string rate = (string.Format("{0:N2}", ((50 / 3) * CallDuration)));
double payment = Convert.ToDouble(rate);
Console.Write(payment);
since I can only divide 50 by 3 to get the equivalent rate for each minute, and decimal places must not be rounded off
but 1 minute already is 50 as well as 2 and 3.
4 5 and 6 will be 100
7 8 9 will be 150
and so on,
can't find a way for this..
#4
Posted 07 September 2010 - 05:44 AM
This should be fairly simple for you to do as long as you're using whole numbers. If the user is truly entering a double then that complicates things a little bit and you may have to do some other calculating but if the rate is the same depending on the range then you should be able to write a function that calculates this. Let the call duration be divided by 3 and then multiply by fifty.
-CDG10620
Software Developer
Software Developer
#5
Posted 08 September 2010 - 06:53 AM
that double should be used that's why i considered it complicated, well if there could be a way, i might look up for it in the near future
#6
Posted 08 September 2010 - 09:39 PM
i still don't understand what you wanted , i am a bit dumb :crying: , analyze the psedocode below and tell i get your question right
Am i getting this right ?
var [COLOR=DarkOrange]_callDuration[/COLOR] = Get from user; var [COLOR=Orange]_ratePerCall [/COLOR]= Fixed by Harddisk [that's you]; var [COLOR=Olive]_callsMade [/COLOR]= _callDuration / 3 ; var [COLOR=Lime]nTotalCost [/COLOR]= [COLOR=MediumTurquoise]_callsMade * _ratePerCall [/COLOR];
Am i getting this right ?
#7
Posted 10 September 2010 - 06:17 AM
This does the trick for me:
int initialAmount = 50;
bool gotDuration = false;
double duration = 0.0;
while (!gotDuration)
{
Console.Write("Please input the duration of the call: ");
string strDuration = Console.ReadLine();
gotDuration = Double.TryParse(strDuration, out duration);
if (!gotDuration)
Console.WriteLine("That is not a valid floating point number, please try again");
}
int charge = Convert.ToInt32(initialAmount * (Math.Ceiling(duration / 3.0)));
Console.WriteLine("Amount needed to be paid: {0}", charge);
#8
Posted 13 September 2010 - 06:56 PM
Matt Ellen said:
This does the trick for me:
int initialAmount = 50;
bool gotDuration = false;
double duration = 0.0;
while (!gotDuration)
{
Console.Write("Please input the duration of the call: ");
string strDuration = Console.ReadLine();
gotDuration = Double.TryParse(strDuration, out duration);
if (!gotDuration)
Console.WriteLine("That is not a valid floating point number, please try again");
}
int charge = Convert.ToInt32(initialAmount * (Math.Ceiling(duration / 3.0)));
Console.WriteLine("Amount needed to be paid: {0}", charge);
i forgot about the ceiling,
Thanx a lot Matt , it worked! :thumbup:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









