Hello, all.

I am trying to calculate entropy, and I cannot get the calculations correct, or match the results with the assigned if-statements. I get a number that differentiates a bit from the answer that I want. So far, this is my code:

#include <iostream>
using namespace std; 
    float Entropy(float z, float z1, float e1, float z0, float e0){
        float e;
        e= e0 + (e1-e0)*((z-z0)/(z1-z0));
        return e;
    int main() {
        float z,e,z1,e1,z0,e0;
        cout << "Enter temp between 150 - 500: ";
        cin >> z;
        else if(z==200){
        else if(z==250){
        else if(z==300){
        else if(z==400){
        else if(z==500){
        else if(z>150&&z<200){
        else if(z>200&&z<250){
        else if(z>250&&z<300){
        else if(z>300&&z<400){
        else if(z>400&&z<500){
            cout << "Temperature out of Range" << endl;
        cout << "The Entropy is: \t" << Entropy << e << " Kj/(Kg.K)" << endl;
    return 0;

Say I input 250, I would expect 7.7710 as output, but in return the value would add an extra 10. How do I make this more precise? I don't want there to be a 10 added to every output. So instead of 17.7710, I want 7.7710. I feel like this is an easy fix, but something is causing this to add 10 and I am not sure what.

Is your C++ compiler not case sensitive?
You define a function Entropy in your code you call a function entropy.

On line 9, the variables z1,e1,z0,e0 are not used in your main function.
Doesn't your C++ compiler give you a warning about that?
Did you turn warnings off?
Translated your code in C#, which wasn't that hard as only the IO-syntax is a bit different.
It worked.
Perhaps something wrong with the formatting of cout?

Remove the extra Entropy from line #48 to: cout << "The Entropy is: \t" << e << " Kj/(Kg.K)" << endl;