Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 870|回复: 4
打印 上一主题 下一主题

java 程序,,救命!!:(

[复制链接]

18

主题

7

好友

363

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

跳转到指定楼层
1#
发表于 2013-12-2 11:08 PM |只看该作者 |倒序浏览
public class replyq2{
        public static void main(String[]args){
               
                System.out.println("" +celsiusToFahrenheit);
                System.out.println("" +fahrenheitToCelsius);

        }
       
        public static double celsiusToFahrenheit (double celsius){
                for(celsius=40;celsius>31;celsius++)
                celsius=(celsius*9/5)+32;
                return celsius;
        }
       
       
       
        public static double fahrenheitToCelsius (double fahrenheit){
                for(fahrenheit=120;fahrenheit>30;fahrenheit++)
                fahrenheit=(fahrenheit-32)*5/9;
                return fahrenheit;
        }
}


求大神教教我怎么把System.out.println("" +celsiusToFahrenheit);
                System.out.println("" +fahrenheitToCelsius);
丢去给下面处理,然后print出下面运算好的答案




收藏收藏0

5

主题

0

好友

1721

积分

白银长老

喵!

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

2#
发表于 2013-12-2 11:54 PM |只看该作者
看起来你要做的东西大概是这样=。=



private double celsius;
private double fahrenheit;

public class replyq2{
        public static void main(String[]args){
               
              celsiusToFahrenheit();
              fahrenheitToCelsius ()
        }
        
         public static void celsiusToFahrenheit (){
                for(celsius=40;celsius>31;celsius++)
                celsius=(celsius*9/5)+32;
                System.out.println("" +celsiusToFahrenheit);
               
        }
        
        
        
        public static void fahrenheitToCelsius (){
                for(fahrenheit=120;fahrenheit>30;fahrenheit++)
                fahrenheit=(fahrenheit-32)*5/9;
                System.out.println("" +fahrenheitToCelsius);
        }
}


回复

使用道具 举报

10

主题

0

好友

117

积分

高级会员

Rank: 3Rank: 3Rank: 3

3#
发表于 2013-12-3 12:34 AM |只看该作者
你要的是不是这样?
public static void main(String[]args){
               
                System.out.println(celsiusToFahrenheit(37));
                System.out.println(fahrenheitToCelsius(220));
        }

还有你的for loop好像会infinite loop
话说你也好像不用用到loop吧


回复

使用道具 举报

3

主题

0

好友

702

积分

青铜长老

Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7Rank: 7

4#
发表于 2013-12-3 08:40 PM |只看该作者
本帖最后由 slay_alex92 于 2013-12-3 09:01 PM 编辑

我15行就搞定了 你看一下
  1. public class q2
  2. {
  3.         public static void main(String[] args){
  4.                 System.out.println(celsiusToFahrenheit(50));
  5.                 System.out.println(fahrenheitToCelsius(100));
  6.         }
  7.        
  8.         public static double celsiusToFahrenheit(double celsius){
  9.                 return celsius * 9 / 5 + 32;
  10.         }
  11.        
  12.         public static double fahrenheitToCelsius(double fahrenheit){
  13.                 return (fahrenheit - 32) * 5 / 9;
  14.         }
  15. }
复制代码


回复

使用道具 举报

0

主题

0

好友

210

积分

支柱会员

Rank: 4Rank: 4Rank: 4Rank: 4

5#
发表于 2014-2-9 12:15 PM |只看该作者
  1. public class replyq2{
  2.         public static void main(String[]args){
  3.                
  4.                 celsiusToFahrenheit(32);
  5.                 fahrenheitToCelsius(90);
  6.         }
  7.         
  8.          public static void celsiusToFahrenheit (double celsius){     
  9.                 System.println(celsius=(celsius*9/5)+32);
  10.         }
  11.         
  12.         public static void fahrenheitToCelsius (double fahrenheit){
  13.                 System.println((fahrenheit-32)*5/9);
  14.         }
  15. }
复制代码
应该是没有错的


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2025-10-5 03:39 PM , Processed in 0.101597 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部