Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

# JAVA HELP!

### #1 DeepIndian Posted 27 February 2010 - 10:30 PM

DeepIndian

New Member

• Member
• 2 posts
Hi I am new to Java language and I have this homework assignment that I have to finish my tomorrow. I am using NetBeans. My assignment is:

Mathematical Model for Loss of Heat

The loss of heat from a hot object depends upon the difference in temperature between the object and the air. An equation for this, to be plotted recursively through many steps in time, is:

Tnew = Told - m(Told - Tair)

In a Java program, plot this equation through a time period of 60 minutes using a loop. You may need to check out the loop syntax in the “How To Think Like A Computer Scientist” Textbook. Receive user input for m (which can be taken to represent the insulating capacity of the object's wrapping), Tair (the air temperature), and Told (which at the beginning of the run is the starting temperature of the hot object); the loop should be incremented by 1, representing a time step of 1 minute.

Hint: You won't have to store anything in an array, if you don't want to, and since the temperature of the hot sample must change constantly through time, you will have to update Told at the end of the loop, after the plot is performed; update it to the current Tnew, like this:

Told = Tnew;

• 0

### #2 coyne20 Posted 19 October 2010 - 05:04 AM

coyne20

Member

• Member
• 35 posts
This simulates your problem in java.

import java.util.Scanner;
import java.text.DecimalFormat;

public class HeatDissipation
{
public void displayHeatDissipation(double m, double Told, double Tair)
{
DecimalFormat twodp = new DecimalFormat("0.00");
int count = 1;
do
{
double Tnew = Told - m * (Told - Tair);
System.out.println("At "+count+" sec , the temp is: "+twodp.format(Tnew)+" degrees celsius.");

double Temp = Told;
Told = Tnew;
Tnew = Temp;

count++;
}
while(count < 61);
}

public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the heat loss / insulation co-efficient: ");
double m = sc.nextDouble();
System.out.println("Enter the current air temperature: ");
double Tair = sc.nextDouble();
System.out.println("Enter the original temperature: ");
double Told = sc.nextDouble();
HeatDissipation hd = new HeatDissipation();
hd.displayHeatDissipation(m, Told, Tair);
}
}
• 0

### Similar Topics

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users