java 类*******没有主方法,是怎么回事
下面是程序importjava.io.*;//tellsJavainputwillbeusedclassPartThree5{publicclassConvertingF...
下面是程序
import java.io.*; //tells Java input will be used
class PartThree5
{
public class ConvertingFahrenheit
{
int fahrenheit;
int celsius;
public void convertingF() {
fahrenheit = (9 / 5) * celsius + 32;
System.out.println(celsius+ " celsius"+ " = " + fahrenheit + " fahrenheit" );
}
}
public class ConvertingCelsius
{
int fahrenheit;
int celsius;
public void convertingC() {
celsius = (5 / 9) * (fahrenheit - 32);
System.out.println (fahrenheit+" fahrenheit=" + celsius + " celsius");
}
}
public class ConvertingTester{
public static void main(String [] args) throws IOException
{
String inData;
ConvertingFahrenheit cf= new ConvertingFahrenheit();
ConvertingCelsius cc= new ConvertingCelsius();
InputStreamReader inStream = new InputStreamReader (System.in);
BufferedReader stdin = new BufferedReader (inStream);
System.out.println ("Input fahrenheit:");
inData = stdin.readLine ();
cf.fahrenheit = Integer.parseInt (inData);
System.out.println ("Input celsius:");
inData = stdin.readLine ( );
cc.celsius= Integer.parseInt (inData); /*converts inData character
data to int data type*/
}
Design an object oriented Celsius-Fahrenheit converter program. Your program will have two methods—one for converting Celsius temperature to Fahrenheit temperature and one method for converting Fahrenheit temperature to Celsius temperature. The user will input a temperature on one temperature scale and the program will output the converted temperature.
Your method should have a return type and one parameter. The formula for conversion is:
fahrenheit = (9.0 / 5.0) * celcius + 32
谢谢啦 展开
import java.io.*; //tells Java input will be used
class PartThree5
{
public class ConvertingFahrenheit
{
int fahrenheit;
int celsius;
public void convertingF() {
fahrenheit = (9 / 5) * celsius + 32;
System.out.println(celsius+ " celsius"+ " = " + fahrenheit + " fahrenheit" );
}
}
public class ConvertingCelsius
{
int fahrenheit;
int celsius;
public void convertingC() {
celsius = (5 / 9) * (fahrenheit - 32);
System.out.println (fahrenheit+" fahrenheit=" + celsius + " celsius");
}
}
public class ConvertingTester{
public static void main(String [] args) throws IOException
{
String inData;
ConvertingFahrenheit cf= new ConvertingFahrenheit();
ConvertingCelsius cc= new ConvertingCelsius();
InputStreamReader inStream = new InputStreamReader (System.in);
BufferedReader stdin = new BufferedReader (inStream);
System.out.println ("Input fahrenheit:");
inData = stdin.readLine ();
cf.fahrenheit = Integer.parseInt (inData);
System.out.println ("Input celsius:");
inData = stdin.readLine ( );
cc.celsius= Integer.parseInt (inData); /*converts inData character
data to int data type*/
}
Design an object oriented Celsius-Fahrenheit converter program. Your program will have two methods—one for converting Celsius temperature to Fahrenheit temperature and one method for converting Fahrenheit temperature to Celsius temperature. The user will input a temperature on one temperature scale and the program will output the converted temperature.
Your method should have a return type and one parameter. The formula for conversion is:
fahrenheit = (9.0 / 5.0) * celcius + 32
谢谢啦 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询