Need help...

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2009
Posts: 11
Reputation: memory100 is an unknown quantity at this point 
Solved Threads: 0
memory100 memory100 is offline Offline
Newbie Poster

Need help...

 
0
  #1
Nov 10th, 2009
WELL i have five questiosn to answer and use console applciation in c# to answer them in here is the first qeustion:
  1. 2. A telephone company charges its customers 3.5p for each minute they use the phone during the day, 5.4p for each minute during the evening, and 6.25p for each minute during weekends. They also charge a line rental of £11 per month irrespective of whether or not any calls have been made. The total charge is subject to VAT at a rate of 17.5%.
  2.  
  3. Write a program which reads in the total number of minutes of calls made by a customer in a month at each of the three rates and calculates the total cost.
  4.  
  5. The outputs required are:
  6.  
  7. Number of minutes of daytime calls, number of minutes of evening calls, number of minutes of weekend calls, costs of daytime, evening and weekend calls, the line rental, a sub-total charge, VAT payable and total charge.

here is the code i have come with so far!!:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication4
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Single daymin = 3.5f;
  13. Single dayeven = 5.4f;
  14. Single weekends = 6.25f;
  15. Single totaldaymin = 0;
  16.  
  17. Console.WriteLine("\n enter amount of minutes");
  18. daymin = Convert.ToInt32(Console.ReadKey());
  19.  
  20. totaldaymin = daymin * 3.5f;
  21.  
  22.  
  23.  
  24. Console.ReadKey();
  25.  
  26. }
  27. }
  28. }
^^^ how to finish this off????so confused on how to do this question???
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 447
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 86
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Pro in Training
 
0
  #2
Nov 10th, 2009
You have started on the right track. Just break down the question.
Often it helps to map out the required operations in pseudocode. Just focus on what you need to read in, process and output at this stage, then worry about the syntax afterwards.

Your question already tells you everything you need to do:

  1. Retrieve values from user:
  2. -Number of daytime minutes (you have done this already)
  3. -Number of evening minutes
  4. -Number of weekend minutes
  5.  
  6. Calculate:
  7. -Cost of daytime (you have done this already)
  8. -Cost of evening
  9. -Cost of weekend
  10. -Subtotal = Total of all three + line rental
  11. -VAT = 17.5% of subtotal
  12. -Total = subtotal+VAT
  13.  
  14. Output values to user

your next step is to go through each of those points and work out what you need to do to accomplish it. Learning to break a problem down into its individual stages is a key skill you will need to develop as a programmer.

Taking the time to do a full analysis and design before you start coding will allow you to produce much cleaner, more efficient code
Last edited by Ryshad; Nov 10th, 2009 at 12:07 pm.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 447
Reputation: Ryshad has a spectacular aura about Ryshad has a spectacular aura about Ryshad has a spectacular aura about 
Solved Threads: 86
Ryshad's Avatar
Ryshad Ryshad is offline Offline
Posting Pro in Training
 
0
  #3
Nov 10th, 2009
oh, one other thing..might be better to use Console.ReadLine() rather than ReadKey()...unless you never use your phone, i imagine you would probably use more than 9 minutes in each period in a whole month.
Last edited by Ryshad; Nov 10th, 2009 at 12:09 pm.
Please don't take for granted the work that solvers do for you. Take the time to fully understand the code they give you so that you might adapt it to future problems.

"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 11
Reputation: memory100 is an unknown quantity at this point 
Solved Threads: 0
memory100 memory100 is offline Offline
Newbie Poster
 
0
  #4
Nov 10th, 2009
ok thnxs for the advice guys is this fully finished :
  1. Single daymin = 3.5f;
  2. Single dayeven = 5.4f;
  3. Single weekends = 6.25f;
  4. Single totaldaymin = 0;
  5. Single totaldayeven = 0;
  6. Single totalweekends = 0;
  7. Single totalofallthree = 0;
  8.  
  9. Console.WriteLine("\n enter amount of minutes used in the daytime");
  10. daymin = Convert.ToInt32(Console.ReadLine());
  11. totaldaymin = daymin * 3.5f;
  12.  
  13. Console.WriteLine("\n enter amount of minutes used in the evening");
  14. dayeven = Convert.ToInt32(Console.ReadLine());
  15. totaldayeven= dayeven * 5.4f;
  16.  
  17. Console.WriteLine("\n enter amount of minutes used on the weekends");
  18. weekends = Convert.ToInt32(Console.ReadLine());
  19. totalweekends = weekends * 3.5f;
  20.  
  21. totalofallthree = (totaldaymin + totaldayeven + totalweekends);
  22.  
  23. Console.WriteLine(totalofallthree);
  24.  
  25.  
  26. Console.ReadKey();
plus i entered the values 1 for each time it asked me to make sure it was working ok but its not as:3.5+5.4+ 6.25= 15.5 when i ran the program it gives me this value...
http://i.imagehost.org/0473/outputvalue.jpg

^^ there is screenshot any ideas why this is happening??
thnxs..
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 11
Reputation: memory100 is an unknown quantity at this point 
Solved Threads: 0
memory100 memory100 is offline Offline
Newbie Poster
 
0
  #5
Nov 10th, 2009
^^^never mind problem solved notice i have dupe "3.5f" values in the calculations..
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 11
Reputation: memory100 is an unknown quantity at this point 
Solved Threads: 0
memory100 memory100 is offline Offline
Newbie Poster
 
0
  #6
Nov 10th, 2009
iv times 0.175 by the subtotal i get form the three added up is this right:
  1. Single daymin = 3.5f;
  2. Single dayeven = 5.4f;
  3. Single weekends = 6.25f;
  4. Single totaldaymin = 0;
  5. Single totaldayeven = 0;
  6. Single totalweekends = 0;
  7. Single subtotal = 0;
  8. Single totalofallthree = 0;
  9. Single vat = 0.175f;
  10.  
  11. Console.WriteLine("\n enter amount of minutes used in the daytime");
  12. daymin = Convert.ToInt32(Console.ReadLine());
  13. totaldaymin = daymin * 3.5f;
  14.  
  15. Console.WriteLine("\n enter amount of minutes used in the evening");
  16. dayeven = Convert.ToInt32(Console.ReadLine());
  17. totaldayeven= dayeven * 5.4f;
  18.  
  19. Console.WriteLine("\n enter amount of minutes used on the weekends");
  20. weekends = Convert.ToInt32(Console.ReadLine());
  21. totalweekends = weekends * 6.25f;
  22.  
  23. subtotal = (totaldaymin + totaldayeven + totalweekends);
  24.  
  25. subtotal = totalofallthree * vat;
  26.  
  27. Console.WriteLine(subtotal);
  28.  
  29.  
  30. Console.ReadKey();

one problem it gives the alue of o whenevr i test the program!!!
Last edited by memory100; Nov 10th, 2009 at 2:10 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 11
Reputation: memory100 is an unknown quantity at this point 
Solved Threads: 0
memory100 memory100 is offline Offline
Newbie Poster
 
0
  #7
Nov 10th, 2009
this ones the final final one::i have doen is this ok? sorry for so many posts..
  1. Single daymin = 3.5f;
  2. Single dayeven = 5.4f;
  3. Single weekends = 6.25f;
  4. Single totaldaymin = 0;
  5. Single totaldayeven = 0;
  6. Single totalweekends = 0;
  7. Single subtotal = 0;
  8. Single totalofallthree = 0;
  9. Single vat = 0.175f;
  10.  
  11. Console.WriteLine("\n enter amount of minutes used in the daytime");
  12. daymin = Convert.ToInt32(Console.ReadLine());
  13. totaldaymin = daymin * 3.5f;
  14.  
  15. Console.WriteLine("\n enter amount of minutes used in the evening");
  16. dayeven = Convert.ToInt32(Console.ReadLine());
  17. totaldayeven= dayeven * 5.4f;
  18.  
  19. Console.WriteLine("\n enter amount of minutes used on the weekends");
  20. weekends = Convert.ToInt32(Console.ReadLine());
  21. totalweekends = weekends * 6.25f;
  22.  
  23. totalofallthree = (totaldaymin + totaldayeven + totalweekends);
  24.  
  25. subtotal = totalofallthree * vat;
  26.  
  27. Console.WriteLine("this is the total charge with the added 17.5% vat",subtotal);
  28.  
  29. Console.WriteLine(subtotal);
  30. Console.WriteLine("");
  31.  
  32. Console.ReadKey();
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,023
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 300
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic
 
0
  #8
Nov 10th, 2009
You are doing very well and listened very well to the advise of Ryshad!
Carry on!
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 11
Reputation: memory100 is an unknown quantity at this point 
Solved Threads: 0
memory100 memory100 is offline Offline
Newbie Poster
 
0
  #9
Nov 10th, 2009
ok well i have problem:
  1. Single daymin = 3.5f;
  2. Single dayeven = 5.4f;
  3. Single weekends = 6.25f;
  4. Single totaldaymin = 0;
  5. Single totaldayeven = 0;
  6. Single totalweekends = 0;
  7. Single subtotal = 0;
  8. Single linerental = 0;
  9. Single totalcharge = 0;
  10. Single vat = 0.175f;
  11. float mounth = 11.0f;
  12. Console.WriteLine("\n enter amount of minutes used in the daytime");
  13. daymin = Convert.ToInt32(Console.ReadLine());
  14. totaldaymin = daymin * 3.5f;
  15.  
  16. Console.WriteLine("\n enter amount of minutes used in the evening");
  17. dayeven = Convert.ToInt32(Console.ReadLine());
  18. totaldayeven= dayeven * 5.4f;
  19.  
  20. Console.WriteLine("\n enter amount of minutes used on the weekends");
  21. weekends = Convert.ToInt32(Console.ReadLine());
  22. totalweekends = weekends * 6.25f;
  23.  
  24. linerental = (totaldaymin + totaldayeven + totalweekends);
  25.  
  26. subtotal = linerental + mounth;
  27. Console.WriteLine("This is line rental with £11 added which is mounthly charged", subtotal);
  28. Console.WriteLine(subtotal);
  29.  
  30. totalcharge = subtotal* vat;
  31.  
  32. Console.WriteLine("this is the total charge with the added 17.5% vat added",totalcharge);
  33.  
  34. Console.WriteLine(totalcharge);
  35. Console.WriteLine("");
  36.  
  37. Console.ReadKey();
thats my finished code i type in values for the day , evening and weekend as 2, it add 11 to this number and then times the total by 0.175(the 17.5%)..in the calculator it shows diffrent form the value in the console app.. any clues why here is a screenshot..::
http://i.imagehost.org/0930/outputvalue.jpg

please help very fonfused of the two answers!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,023
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 300
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Postaholic
 
0
  #10
Nov 10th, 2009
Your program code is correct, your calculator calculation is wrong.
On the calculator you calculate (2+2+2+11)*0.175 = 2.975
Your program calculates (2*3.5 + 2*5.4 + 2*6.25 +11)*0.175 = 7.2275
Last edited by ddanbe; Nov 10th, 2009 at 3:36 pm.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Reply

Tags
c#

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for c#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC