WELL i have five questiosn to answer and use console applciation in c# to answer them in here is the first qeustion:

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!!:

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();

        }
    }
}

^^^ how to finish this off????so confused on how to do this question???

Recommended Answers

All 13 Replies

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:

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 :)

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.

ok thnxs for the advice guys is this fully finished :

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();

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..

^^^never mind problem solved notice i have dupe "3.5f" values in the calculations..

iv times 0.175 by the subtotal i get form the three added up is this right:

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!!!

this ones the final final one::i have doen is this ok? sorry for so many posts..

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();

You are doing very well and listened very well to the advise of Ryshad!
Carry on!

ok well i have problem:

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();

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!!

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

ohh^^^i see forgot about the timesing of the numbers thnxs^^was so upset lol im happy now thnak you.. you knwo how to store a text file in programming?

thank you can someoen close this thread or delete it because i have to hand this in... do ot want to penlized for forgery..

If you want to close the thread, mark it as solved!

Well done, i'm glad to see my advice helped :) It's so much more rewarding to work through the problem yourself than to have someone give you the code. Just remember this for your future projects; a little effort at the planning stage will save you a lot of effort in the coding stage.

Only one small thing i would recommend; at the end you are showing the subtotal Console.WriteLine(subtotal); , then showing the amount of the VAT Console.WriteLine(totalcharge); but calling it the total. You should display the VAT, then add that to the total to show the total:

vat = subtotal* 0.175;
Console.WriteLine("this is the total vat added at 17.5% ",vat);
Console.WriteLine(vat);

totalcharge = subtotal* vat;
Console.WriteLine("this is the total charge with the added vat added",totalcharge);
Console.WriteLine(totalcharge);

I'm afraid you can't remove the thread, you can only mark it as solved. You can try contacting a moderator but as far as i'm aware they dont usually remove code from threads.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.