JAVA语言程序设计(基础篇)第十版课后题答案(第一章)

    xiaoxiao2025-01-28  49

    JAVA语言程序设计(基础篇)第十版课后题答案 第一章 第二题 /**

    Created by ysy on 2018/7/6. */ public class text2 {

    public static void main(String[] args){ for(int i = 0; i < 5; i++) System.out.println(“Welcome to Java”); }

    }

    第三题 /**

    Created by ysy on 2018/7/6. */ public class text3 { public static void main(String[] args){ System.out.println(" J A V V A"); System.out.println(" J A A V V A A"); System.out.println(“J J AAAAA V V AAAAA”); System.out.println(" JJ A A V A A"); } } 第四题 import java.util.Scanner;

    /**

    Created by ysy on 2018/7/6. *对输入数据求解一次方,平方,三次方 */ public class text4 {

    public static void main(String[] args){

    Scanner input = new Scanner(System.in); char[] temp = new char[10]; int num; for(int i = 0; i < 5; ++i){ String Stemp; System.out.println("请输入数据:"); Stemp = input.next(); temp = Stemp.toCharArray(); if(temp[0] >= 'a' && temp[0] <= 'z'){ System.out.println(temp[0]+" "+temp[0]+"^2 " + temp[0] + "^3"); } else if(temp[0] >= '0' && temp[0] <= '9'){ num = temp[0] - '0'; System.out.println(num+" "+(int)Math.pow(num, 2)+" "+(int)Math.pow(num, 3)); } }

    } }

    第七题 import java.util.Scanner;

    /**

    Created by ysy on 2018/7/6. *对输入数据求解一次方,平方,三次方 */ public class text4 {

    public static void main(String[] args){

    Scanner input = new Scanner(System.in); char[] temp = new char[10]; int num; for(int i = 0; i < 5; ++i){ String Stemp; System.out.println("请输入数据:"); Stemp = input.next(); temp = Stemp.toCharArray(); if(temp[0] >= 'a' && temp[0] <= 'z'){ System.out.println(temp[0]+" "+temp[0]+"^2 " + temp[0] + "^3"); } else if(temp[0] >= '0' && temp[0] <= '9'){ num = temp[0] - '0'; System.out.println(num+" "+(int)Math.pow(num, 2)+" "+(int)Math.pow(num, 3)); } }

    } }

    第八题

    /**

    Created by ysy on 2018/7/6. */ public class text8 { static double pi=3.14; public static void main(String arg[]){

    double r=5.5; double a=getLength(r); double b=getArea(r); System.out.println("周长:"+a); System.out.println("面积:"+b);

    }

    public static double getLength(double r){ return 2rpi; }

    public static double getArea(double r){ return rrpi; }

    }

    第九题 /**

    Created by ysy on 2018/7/6. */ public class text9 { public static void main(String[] arg){ double a=14/1.6; double t=45.5/60; double v=a/t; System.out.println(“速度”+v); } }

    第十一题

    /**

    Created by ysy on 2018/7/6. / public class text11 { public static void main(String arg[]){ int now_num=312032486; int time=365246060; int spring=time/7; int die=time/13; int move=time/45; int num=now_num+spring-die+move; System.out.println(num); } }

    第十二题

    /**

    Created by ysy on 2018/7/6. / public class text12 { public static void main(String[] arg){ double a=3.4; double b=50.24; double c=2.1; double d=0.55; double e=44.5; double f=5.9; double x=(ed-bf)/(ad-bc); double y=(af-ec)/(ad-b*c); System.out.println(“x:”+x); System.out.println(“y:”+y);

    } }

    最新回复(0)