栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java语言程序设计与数据结构(基础篇)课后练习题 第四章

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java语言程序设计与数据结构(基础篇)课后练习题 第四章

System.out.println("The three angles are: “+aa+” “+ab+” "+ac);

}

}

[](()4.7

================================================================

import java.util.Scanner;

public class disizhang {

public static void main(String[] args){

final double PI = 3.141592654;

Scanner input = new Scanner(System.in);

System.out.print("Enter the radius of the bounding circle: ");

double r = input.nextDouble();

double base = 0.1*PI;

System.out.println(“The coordinates of fibe points on the pentagon are”);

for(int i=0;i<5;i++)

{

System.out.printf(“(%.2f, %.2f)%n”,rMath.cos(base),rMath.sin(base));

base+=0.4*PI;

}

}

}

[](()4.8

================================================================

import java.util.Scanner;

public class disizhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Ent6er an ASCII code: ");

int num = input.nextInt();

char str = (char)num;

System.out.printf(“The character for ASCII code %d is %c”,num,str);

}

}

[](()4.9

================================================================

import java.util.Scanner;

public class disizhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Enter a character: ");

String jb = input.nextLine();

char str = jb.charAt(0);

int str2 = (int)str;

System.out.printf(“The Unicode for the character %c is %d”,str,str2);

}

}

[](()4.10

=================================================================

public class disizhang {

public static void main(String[] args)

{

//在原来代码中进行修改

int answer = input.nextInt()修改为:char answer = input.nextLine().charAt(0)

if(answer1)—>if(answer’Y’)

}

}

[](()4.11

=================================================================

import java.util.Scanner;

public class disizhang {

public static void main(String[] args){

System.out.print("Enter a decimal value (0 to 15): ");

Scanner input = new Scanner(System.in);

int num = input.nextInt();

if(num>=0&&num<=15){

if(num<10)

System.out.printf(“The hex value is %d”,num);

else

System.out.printf(“The hex value is %c”,‘A’+num-10);

}else

System.out.printf(“%d is an invalid input”,num);

}

}

[](()4.12

=================================================================

import java.util.Scanner;

public class disizhang {

public static void main(String[] args){

String[] bins = {“0”,“1”,“10”,“11”,“100”,“101”,“110”,“111”,“1000”,“1001”,“1010”,“1011”,“1100”,“1101”,“1110”,“1111”};

System.out.print("Enter a hex digit: ");

Scanner input = new Scanner(System.in);

char str = input.nextLine().charAt(0);

if(str>=‘0’&&str<=‘9’)

System.out.printf(“The binary value is %sn”,bins[str-‘0’]);

else if(str>=‘A’&&str<=‘F’)

System.out.printf(“The binary value is %sn”,bins[str-‘A’+10]);

else

System.out.printf(“%c is an invalid inputn”,str);

}

}

[](()4.13

=================================================================

import java.util.Scanner;

public class disizhang {

public static void main(String[] args){

Scanner input = new Scanner(System.in);

System.out.print("Enter a letter: ");

char str = input.nextLine().charAt(0);

if((str<=‘z’&&str>=‘a’)||(str<=‘Z’&&str>=‘A’))

{

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/820469.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号