ImageVerifierCode 换一换
格式:DOCX , 页数:51 ,大小:22.76KB ,
资源ID:10541044      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/10541044.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java答案.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java答案.docx

1、java答案import java.util.*;public class Q1 public static void main(String args) Scanner input = new Scanner (System.in); System.out.print(Enter a degree in Celsius: ); double c = input.nextDouble(); double f; f = 9.0 / 5 * c + 32; System.out.println(c + Celsius is + f + Fahrenheit); import java.util.*

2、;public class Q2 public static void main(String args) Scanner input = new Scanner (System.in); System.out.print(Enter an ASCII code: ); int num = input.nextInt(); char letter = (char) num; System.out.println(The character for ASCII code + num + is + letter); import java.util.*;public class Q3 public

3、 static void main(String args) Scanner input = new Scanner(System.in); System.out.print(Enter a number between 0 and 1000: ); int num = input.nextInt(); int unit = num % 10; int decade = num / 10 % 10; int hundred = num / 100; int sum = unit + decade + hundred; System.out.println(The sum of the digi

4、ts is + sum); import java.util.*;public class Q4 public static void main(String args) final int MAXSIZE = 100; int student = new intMAXSIZE; int best = 0; Scanner input = new Scanner(System.in); System.out.print(Enter the number of students: ); int num = input.nextInt(); System.out.print(Enter + num

5、 + scores: ); for(int i = 0 ; i best) best = studenti; for(int i = 0 ; i = best - 10) System.out.println(Student + i + score is + studenti + and grade is A); else if(studenti = best - 20) System.out.println(Student + i + score is + studenti + and grade is B); else if(studenti = best - 30) System.out

6、.println(Student + i + score is + studenti + and grade is C); else if(studenti = best - 40) System.out.println(Student + i + score is + studenti + and grade is D); else System.out.println(Student + i + score is + studenti + and grade is F); import java.util.*;public class Q1 public static void main(

7、String args) String represent = new String3; Scanner input = new Scanner(System.in); Random random = new Random(); represent0 = scissor; represent1 = rock; represent2 = paper; System.out.print(scissor (0), rock (1), paper (2): ); int com = random.nextInt(3); int user = input.nextInt(); if(com = user

8、) System.out.println(The computer is + representcom + . You are + representuser + too. It is a draw.); else if(com = 0&user = 1)|(com = 1&user = 2)|(com = 2&user = 0) System.out.println(The computer is + representcom + . You are + representuser + . You win); else System.out.println(The computer is +

9、 representcom + . You are + representuser + . You lose); import java.util.*;public class Q2 public static void main(String args) Scanner input = new Scanner(System.in); boolean result; System.out.print(Enter three edges: ); double a = input.nextDouble(); double b = input.nextDouble(); double c = inp

10、ut.nextDouble(); System.out.print(Can edges + a + , + b + , and + c + form a triangle? ); if(a + b c & a + c b & b + c a) result = true; else result = false; System.out.println(result); import java.util.*;public class Q3 public static void main(String args) int digit = new int9; Scanner input = new

11、Scanner(System.in); System.out.print(Input an integer to calculate ISBN(Only nine digits): ); int data = input.nextInt(); int checksum = 0; int temp = data; for(int i = 0 ; i = 0 ; i-) System.out.print(digiti); if(checksum = 10) System.out.println(X); else System.out.println(checksum); import java.u

12、til.*;public class Q1 public static void main(String args) print(chicks,chick); print(cows,moo); print(ducks,quack); print(pigs,oink); public static void print(String word1,String word2) System.out.println(Old MacDonald had a farm Old MacDonald had a farm, e i e i o); System.out.println(And on his f

13、arm he had some + word1 + , e i e i o); System.out.println(with a + word2 + word2 + here and a + word2 + + word2); System.out.println(there); System.out.println(here a + word2 + there a + word2); System.out.println(everywhere a + word2 + + word2); System.out.println(Old MacDonald had a farm, e i e i

14、 o); System.out.println(); import java.util.*;public class Q2 public static void main(String args) Scanner input = new Scanner (System.in); System.out.print(Input how many Fibonacci numbers you want to print: ); int num = input.nextInt(); for(int i = 1 ; i = 0 ; i-) if(hexai 9) switch(hexai) case 10

15、:System.out.print(A);break; case 11:System.out.print(B);break; case 12:System.out.print(C);break; case 13:System.out.print(D);break; case 14:System.out.print(E);break; case 15:System.out.print(F);break; else System.out.print(hexai); System.out.println(); import java.util.*;public class Q4 public sta

16、tic void main(String args) for(int i = 3 ; i 998 ; i += 2) int j = i + 2; if(Prime(i) & Prime(j) System.out.println( + i + , + j + ); public static boolean Prime(int num) for(int i = 2 ; i = Math.sqrt(num) ; i+) if(num % i = 0) return false; return true; import java.util.*;public class CoutingOccurr

17、enceOfNumbers static final int MAXSIZE = 100; public static void main(String args) Scanner input = new Scanner(System.in); int array1 = new intMAXSIZE; int array2 = new int101; System.out.print(Enter the integers betwenn 1 and 100:); for(int i = 0; i 101; i+) array2i = 0; for(int i = 0; ; i+) array1

18、i = input.nextInt(); array2array1i+; if(array1i = 0) break; for(int i = 1; i 101; i+) if(array2i != 0) System.out.println(i + occurs + array2i + times); import java.util.*;public class EliminatingDuplicate static int length = 0; public static void main(String args) int numbers = new int10; System.ou

19、t.print(Enter ten numbers:); int result = eliminatingDuplicates(numbers); System.out.print(The distinct numbers are:); for(int i= 0 ; i = length ; i+) System.out.print(resulti + ); public static int eliminatingDuplicates(int numbers) Scanner input = new Scanner(System.in); numbers0 = input.nextInt()

20、; int temp; boolean rep = true; for(int i = 1 ; i 10 ; i+) temp = input.nextInt(); for(int j = 0 ; j = length ; j+) if(numbersj = temp) rep = false; break; if(rep) numbers+length = temp; rep = true; return numbers; import java.util.*;public class IdenticalArrays public static void main(String args)

21、Scanner input = new Scanner(System.in); int n1,n2; System.out.print(Enter list1:); n1 = input.nextInt(); int list1 = new intn1; for(int i = 0 ; i n1 ; i+) list1i = input.nextInt(); System.out.print(Enter list2:); n2 = input.nextInt(); int list2 = new intn2; for(int i = 0 ; i n2 ; i+) list2i = input.

22、nextInt(); System.out.println(Two lists are + (isIdentical(list1,list2) ? identical : not identical); public static boolean isIdentical(int list1,int list2) Arrays.sort(list1); Arrays.sort(list2); if(Arrays.equals(list1,list2) return true; else return false; public class NSideRegularPolygon public s

23、tatic void main(String args) RegularPolygon polygon1 = new RegularPolygon(6,4); RegularPolygon polygon2 = new RegularPolygon(10,4,5.6,7.8); System.out.println(Polygon1:); System.out.println(perimeter: + polygon1.getPerimeter() + area: + polygon1.getArea(); System.out.println(Polygon2:); System.out.p

24、rintln(perimeter: + polygon2.getPerimeter() + area: + polygon2.getArea(); class RegularPolygon int n; double side; double x; double y; RegularPolygon() n = 3; side = 1; x = 0; y = 0; RegularPolygon(int n0,double s0) n = n0; side = s0; x = 0; y = 0; RegularPolygon(int n1,double s1,double x1,double y1) n = n1; side = s1; x = x1; y = y1; double getPerimeter() return n * sid

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1