Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm new in c# and i'm trying to print a receipt. but my codes are wrong, Here is my problem

> Compute the Price multiplied by the quantity given by the user
> Compute the said Amount - 12% tax
> Show the Vat Tax
> Accept money and compute the change
> they have to all appear once the unit price has been inputted

This are my codes at the moment for the computation part
C#
bool test = false;
do
{
    try
    {
        Console.SetCursorPosition(2, 12);
        Console.Write("       ");

        Console.SetCursorPosition(2, 12);
        Num = Convert.ToInt32(Console.ReadLine());
        test = false;
    }
    catch
    {
        test = true;
    }
} while (test);

Console.SetCursorPosition(18, 12);
Console.ForegroundColor = ConsoleColor.Yellow;
telNumber = Console.ReadLine();

//Peso

bool Ptest = false;
do
{
    try
    {
        Console.SetCursorPosition(47, 12);
        Console.Write("       ");
        Console.SetCursorPosition(47, 12);
        Amount = Convert.ToInt32(Console.ReadLine());
        Console.SetCursorPosition(65, 12);
        Amount = Amount * 2 ;
       
        Console.WriteLine("P   " + Amount.ToString("0.00"));

        Console.SetCursorPosition(65, 15);
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("P   " + Amount.ToString("0.00"));

        Console.SetCursorPosition(65, 17);
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("P   " + Amount.ToString("0.00"));
          
        Ptest = false;
    }
    catch
    {
        Ptest = true;
    }
} while (Ptest);

//Amount

Console.ReadLine();

It has to look like this, Ive done the format but im having trouble with the said problems above, please help

Image at - http://static.tumblr.com/xklso8y/PUfng8s5h/clipboard01.png[^]


[Edit member="Tadit"]
Link text added to reflect the Article/QA title.
Corrected formatting and/or grammatical issues.
Added pre tags.
[/Edit]
Posted
v2
Comments
ZurdoDev 7-Dec-14 22:00pm    
Where exactly are you stuck?
Member 11293260 7-Dec-14 22:21pm    
In the computation process, You see, the user must input only integer value on Qty, Unit Price, then it will be multiplied Unit Price times Quantity and will display on Amount, along with tax which is 12% and Total tax on price,

Here's what the correct thing look like, please see the image

http://static.tumblr.com/xklso8y/PUfng8s5h/clipboard01.png
BillWoodruff 8-Dec-14 0:28am    
Change the Type of all your integer variables to 'double, and then, when you need to, display a result without decimal remainder, or with two digits of decimal showing use string.Format

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

And so far, you have done the outside structure, but not tried to do any of the actual computations.
You know how to multiply, you know what a percentage is: so (as Bill says) convert your integers to doubles, and try adding the code to do the computations: this is not a complex task, and if you can't work out how to do this yourself, you are going to have real trouble with your next homework task!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900