I was asked to create a program that calculate heat energy[Q=mc(delta)T] using if, if...else and switch case but I don't know how to do it. Can anyone help me?(One program for each case)
What, exactly are these programs meant to do? If it's just calculating energy then why do you need 2 programs?
The way you've described the problem i dont see why you'd have to have any if/else/switch statements in there. Unless you are talking in terms of validation. for example:
(psuedocode:
1 2 3 4 5 6 7
if(t1 > t2)
{
// if this is true your subtraction on line 30 will come out as negative
// so here you might want to multiply t2 - t1 by minus 1 to get a positive
// result.
}
OR you could tell the user if your mass is cooling or heating up say.
psuedocode:
if(t1 < t2)
{
print "body is getting hotter"
}
else
{
print "body is cooling"
}
Do you have a more detailed description of the problem that you can post here? Are you supposed to be running the calculation for different materials, different conditions? It's not clear from what you've posted so far why an if/else or switch statement would be needed.