Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need Help With a Turbo Pascal Program for class

PascalHelpPascalHelp Posts: 2Member
The Cluck Egg Company has different prices for their eggs, based upon the number sold:
0 up to but not including 4 dozen: $0.50 per dozen
4 up to but not including 6 dozen: $0.45 per dozen
6 up to but not including 11 dozen: $0.40 per dozen
11 or more dozen : $0.35 per dozen
*Extra eggs are priced at 1/12 the per dozen price each

Write a program that allows the user to input the number of eggs wanted, and then calculates the bill. Example of Output:

Enter number of eggs: [u]126[/u]

Purchase: 10 dozen and 6 extra eggs
Your bill comes to $ 4.20


This program uses if, then, and else. I know how to do this problem, its just I don't know how to put it into a program effectively.

If anybody could help me with this, it would be much appreciated.

Comments

  • DWDuckDWDuck Posts: 31Member
    : The Cluck Egg Company has different prices for their eggs, based
    : upon the number sold:
    : 0 up to but not including 4 dozen: $0.50 per dozen
    : 4 up to but not including 6 dozen: $0.45 per dozen
    : 6 up to but not including 11 dozen: $0.40 per dozen
    : 11 or more dozen : $0.35 per dozen
    : *Extra eggs are priced at 1/12 the per dozen price each
    :
    : Write a program that allows the user to input the number of eggs
    : wanted, and then calculates the bill. Example of Output:
    :
    : Enter number of eggs: [u]126[/u]
    :
    : Purchase: 10 dozen and 6 extra eggs
    : Your bill comes to $ 4.20
    :
    :
    : This program uses if, then, and else. I know how to do this problem,
    : its just I don't know how to put it into a program effectively.
    :
    : If anybody could help me with this, it would be much appreciated.
    :
    Good day firstly I think ur post would have been more appropriate in the pascal forum.

    Never the less here is the code that would do it the best.

    Program EggQoute
    Uses Crt;

    Var
    N,Dozen : Integer;
    PricePDozen, PricePerEgg, Price : Real;

    Begin
    Writeln('How many eggs do u want: ');
    Readln(N);

    Dozen = N div 12;

    Writeln;
    Case Dozen of
    0..3 : PricePerDozen := 0.5;
    4..5 : PricePerDozen := 0.45;
    6..11 : PricePerDozen := 0.4;
    Else PricePerDozen := 0.35;

    PricePerEgg := PricePerDozen /12;

    Price := PricePerEgg * N;

    Writeln('The total cost of your eggs will be: ',Price:2:2);
    Readln;
    End;


    Darkwing Duck aka DWduck signing off :)
Sign In or Register to comment.