Problem, can anyone help. - Programmers Heaven

Howdy, Stranger!

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

Categories

Problem, can anyone help.

odan16odan16 Posts: 40Member
I have written a program to calculate an electricity bill as part of my college assignment and I've just found a problem that I am unable to solve.

The calculations I have done in the program are correct, but when I display the results of calculations involving high numbers (over 1000), they appear incorrectly and I do not understand why. Can anyone tell me how to solve this?

Comments

  • sweeneysweeney Posts: 117Member
    : I have written a program to calculate an electricity bill as part of my college assignment and I've just found a problem that I am unable to solve.
    :
    : The calculations I have done in the program are correct, but when I display the results of calculations involving high numbers (over 1000), they appear incorrectly and I do not understand why. Can anyone tell me how to solve this?
    :
    are you using integer? try using longint; or word; this will give you bigger number abilaty! if not then post some of your code so that we can see where u are going wrong!

    sweeney
  • odan16odan16 Posts: 40Member
    Well the output I want is in real format. I've tried using double but it doesn't work either. The calculations I have done are correct and work fine on numbers under 1000.
  • sweeneysweeney Posts: 117Member
    : Well the output I want is in real format. I've tried using double but it doesn't work either. The calculations I have done are correct and work fine on numbers under 1000.
    :
    nope its ok right do you know decamal places you need to do it in this case! ok give me the output line and I will fix it!
  • sweeneysweeney Posts: 117Member
    : : Well the output I want is in real format. I've tried using double but it doesn't work either. The calculations I have done are correct and work fine on numbers under 1000.
    : :
    : nope its ok right do you know decamal places you need to do it in this case! ok give me the output line and I will fix it!
    :
    see real is decamal numbers! so here is an example

    [code]
    program example;
    uses crt;

    begin
    write(' Enter the price of the product: ');
    readln(price);
    discount := price / 10;
    writeln('The discount is as follows',discount1:2:); {this is where the decamal is read! :1:2: says is the 2 decamle places after the 1st you can chage that to any number you wish!}
    readln; untill enter is presed;
    end.


  • odan16odan16 Posts: 40Member
    Lol omg! I can't believe it! I spent ages looking for the problem and it turns out I just mislabelled a variable. Sorry bout that.
  • sweeneysweeney Posts: 117Member
    : Lol omg! I can't believe it! I spent ages looking for the problem and it turns out I just mislabelled a variable. Sorry bout that.
    :
    lmao duhh lol joking hey glad to help anyways! lol
Sign In or Register to comment.