| | |
Need help...
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 11
Reputation:
Solved Threads: 0
WELL i have five questiosn to answer and use console applciation in c# to answer them in here is the first qeustion:
here is the code i have come with so far!!:
^^^ how to finish this off????so confused on how to do this question???
C# Syntax (Toggle Plain Text)
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%. 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. The outputs required are: 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!!:
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication4 { class Program { static void Main(string[] args) { Single daymin = 3.5f; Single dayeven = 5.4f; Single weekends = 6.25f; Single totaldaymin = 0; Console.WriteLine("\n enter amount of minutes"); daymin = Convert.ToInt32(Console.ReadKey()); totaldaymin = daymin * 3.5f; Console.ReadKey(); } } }
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:
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
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:
C# Syntax (Toggle Plain Text)
Retrieve values from user: -Number of daytime minutes (you have done this already) -Number of evening minutes -Number of weekend minutes Calculate: -Cost of daytime (you have done this already) -Cost of evening -Cost of weekend -Subtotal = Total of all three + line rental -VAT = 17.5% of subtotal -Total = subtotal+VAT 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
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
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
"Learning is more than absorbing facts, it is acquiring understanding.” - William Arthur Ward
•
•
Join Date: Nov 2009
Posts: 11
Reputation:
Solved Threads: 0
0
#4 Nov 10th, 2009
ok thnxs for the advice guys is this fully finished :
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..
C# Syntax (Toggle Plain Text)
Single daymin = 3.5f; Single dayeven = 5.4f; Single weekends = 6.25f; Single totaldaymin = 0; Single totaldayeven = 0; Single totalweekends = 0; Single totalofallthree = 0; Console.WriteLine("\n enter amount of minutes used in the daytime"); daymin = Convert.ToInt32(Console.ReadLine()); totaldaymin = daymin * 3.5f; Console.WriteLine("\n enter amount of minutes used in the evening"); dayeven = Convert.ToInt32(Console.ReadLine()); totaldayeven= dayeven * 5.4f; Console.WriteLine("\n enter amount of minutes used on the weekends"); weekends = Convert.ToInt32(Console.ReadLine()); totalweekends = weekends * 3.5f; totalofallthree = (totaldaymin + totaldayeven + totalweekends); Console.WriteLine(totalofallthree); Console.ReadKey();
http://i.imagehost.org/0473/outputvalue.jpg
^^ there is screenshot any ideas why this is happening??
thnxs..
•
•
Join Date: Nov 2009
Posts: 11
Reputation:
Solved Threads: 0
0
#6 Nov 10th, 2009
iv times 0.175 by the subtotal i get form the three added up is this right:
one problem it gives the alue of o whenevr i test the program!!!
C# Syntax (Toggle Plain Text)
Single daymin = 3.5f; Single dayeven = 5.4f; Single weekends = 6.25f; Single totaldaymin = 0; Single totaldayeven = 0; Single totalweekends = 0; Single subtotal = 0; Single totalofallthree = 0; Single vat = 0.175f; Console.WriteLine("\n enter amount of minutes used in the daytime"); daymin = Convert.ToInt32(Console.ReadLine()); totaldaymin = daymin * 3.5f; Console.WriteLine("\n enter amount of minutes used in the evening"); dayeven = Convert.ToInt32(Console.ReadLine()); totaldayeven= dayeven * 5.4f; Console.WriteLine("\n enter amount of minutes used on the weekends"); weekends = Convert.ToInt32(Console.ReadLine()); totalweekends = weekends * 6.25f; subtotal = (totaldaymin + totaldayeven + totalweekends); subtotal = totalofallthree * vat; Console.WriteLine(subtotal); 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.
•
•
Join Date: Nov 2009
Posts: 11
Reputation:
Solved Threads: 0
0
#7 Nov 10th, 2009
this ones the final final one::i have doen is this ok? sorry for so many posts..
C# Syntax (Toggle Plain Text)
Single daymin = 3.5f; Single dayeven = 5.4f; Single weekends = 6.25f; Single totaldaymin = 0; Single totaldayeven = 0; Single totalweekends = 0; Single subtotal = 0; Single totalofallthree = 0; Single vat = 0.175f; Console.WriteLine("\n enter amount of minutes used in the daytime"); daymin = Convert.ToInt32(Console.ReadLine()); totaldaymin = daymin * 3.5f; Console.WriteLine("\n enter amount of minutes used in the evening"); dayeven = Convert.ToInt32(Console.ReadLine()); totaldayeven= dayeven * 5.4f; Console.WriteLine("\n enter amount of minutes used on the weekends"); weekends = Convert.ToInt32(Console.ReadLine()); totalweekends = weekends * 6.25f; totalofallthree = (totaldaymin + totaldayeven + totalweekends); subtotal = totalofallthree * vat; Console.WriteLine("this is the total charge with the added 17.5% vat",subtotal); Console.WriteLine(subtotal); Console.WriteLine(""); Console.ReadKey();
•
•
Join Date: Nov 2009
Posts: 11
Reputation:
Solved Threads: 0
0
#9 Nov 10th, 2009
ok well i have problem:
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!!
C# Syntax (Toggle Plain Text)
Single daymin = 3.5f; Single dayeven = 5.4f; Single weekends = 6.25f; Single totaldaymin = 0; Single totaldayeven = 0; Single totalweekends = 0; Single subtotal = 0; Single linerental = 0; Single totalcharge = 0; Single vat = 0.175f; float mounth = 11.0f; Console.WriteLine("\n enter amount of minutes used in the daytime"); daymin = Convert.ToInt32(Console.ReadLine()); totaldaymin = daymin * 3.5f; Console.WriteLine("\n enter amount of minutes used in the evening"); dayeven = Convert.ToInt32(Console.ReadLine()); totaldayeven= dayeven * 5.4f; Console.WriteLine("\n enter amount of minutes used on the weekends"); weekends = Convert.ToInt32(Console.ReadLine()); totalweekends = weekends * 6.25f; linerental = (totaldaymin + totaldayeven + totalweekends); subtotal = linerental + mounth; Console.WriteLine("This is line rental with £11 added which is mounthly charged", subtotal); Console.WriteLine(subtotal); totalcharge = subtotal* vat; Console.WriteLine("this is the total charge with the added 17.5% vat added",totalcharge); Console.WriteLine(totalcharge); Console.WriteLine(""); Console.ReadKey();
http://i.imagehost.org/0930/outputvalue.jpg
please help very fonfused of the two answers!!
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
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
Make love, no war. Cave ab homine unius libri.
Danny
![]() |
Other Threads in the C# Forum
- Previous Thread: Using Xml.Linq and writing the schemaLocation
- Next Thread: Setting more than one label to visible.
| Thread Tools | Search this Thread |
Tag cloud for c#
.net access activedirectory ado.net algorithm app array asp.net associations automation bot broadcast c# c++ camera chat code combobox console custom database datagrid datastructure datetime dbconnection default development dialog directrobot dll drawing dropdown dubai e-commerce excel exectuable expression file form gdi+ google httpwebrequest index instance javascript keypress label lisp list listbox login math mdd msword mysql networking open operator oracle packaging path photoshop php picturebox post programming redirect remote remoting reporting resource richtextbox save saving script sendkeys server softwaredevelopment sql sql-server sqlserver ssh statistics string study tables textbox totaldays treeview using-keyword vb vista visualstudio webbrowser webdevelopment windows winforms wpf write xml







