⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod1ans.lst

📁 Mcgraw-Hill - Java 2 - A Beginner S Guide, 2Nd Ed - 2003 -prog.
💻 LST
字号:
listing 1
/*    
   Compute your weight on the moon.  
   
   Call this file Moon.java.   
*/    
class Moon {    
  public static void main(String args[]) {    
    double earthweight; // weight on earth  
    double moonweight; // weight on moon   
   
    earthweight = 165;   
  
    moonweight = earthweight * 0.17;  
   
    System.out.println(earthweight + " earth-pounds is equivalent to " +  
                       moonweight + " moon-pounds.");    
   
  }    
}

listing 2
/*  
   This program displays a conversion  
   table of inches to meters. 
 
   Call this program InchToMeterTable.java. 
*/  
class InchToMeterTable {  
  public static void main(String args[]) {  
    double inches, meters; 
    int counter; 
 
    counter = 0; 
    for(inches = 1; inches <= 144; inches++) { 
      meters = inches / 39.37; // convert to meters 
      System.out.println(inches + " inches is " + 
                         meters + " meters."); 
 
      counter++; 
      // every 12th line, print a blank line        
      if(counter == 12) { 
        System.out.println(); 
        counter = 0; // reset the line counter 
      } 
    } 
  }  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -