import java.text.DecimalFormat;
public class ConvertClass
{
private double tempC;
public ConvertClass()
{
setTempC(0.0);
}
public void setTempC(double c)
{
tempC = c;
}
public double getTempC()
{
return tempC;
}
public double getFahrenheit()
{
double F;
return F = (9*tempC)/5+32;
}
public void prt()
{
DecimalFormat dec = new DecimalFormat("#0.000");
System.out.println("Temperature Centigrade:" +dec.format(getTempC()));
System.out.println("Fahrenheit:" +dec.format(getFahrenheit()));
}
}
import java.util.Scanner;
public class ConvertDemo{
public static void main(String[] args)
{
double bTime,
eTime,
num = 1.0;
Scanner input = new Scanner(System.in);
System.out.println("What is the beginning temperature in centigrade?");
bTime = input.nextDouble();
System.out.println("What is the ending temperature in centigrade?");
eTime = input.nextDouble();
ConvertClass convert = new ConvertClass();
convert.setTempC(bTime);
If(!(bTime <= eTime))
{
System.out.println("Please enter valid Beginning Time and Ending Time.");
System.out.println("Please be sure your begining time is less than ending time.");
}
do {System.out.println("Results: " +convert.prt())}
while(bTime<=eTime);
while(bTime<=eTime)
{
System.out.println("Results: " +convert.prt());
}
for(bTime<=eTime)
{
System.out.println("Results: " +convert.prt());
}
}
Its giving me a bunch of ";" or ")" that I know aren't supposed to be there. Also how would I use the beginning and ending numbers to get centigrade and fahrenhiet from the class?

New Topic/Question
Reply


MultiQuote



|