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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Exam11301Ch123.docx

1、Exam11301Ch123Name:_Covers Chapters 1-3 50 minsCSCI 1301 Introduction to ProgrammingArmstrong Atlantic State UniversityInstructor: Y. Daniel LiangPart I. (10 pts) Show the printout of the following code: (write the printout next to each println statement if the println statement is executed in the p

2、rogram).public class Test public static void main(String args) System.out.println(int)(Math.random(); System.out.println(Math.pow(2, 3); System.out.println(34 % 7);System.out.println(3 + 4 * 2 2 * 9); int number = 4; if (number % 3 = 0) System.out.println(3 * number);System.out.println(4 * number);i

3、nt x = 943;System.out.println(x / 100); System.out.println(x % 100);System.out.println(x + is + (x % 2 = 0) ? even : odd); int y = -1; y+;System.out.println(y); Part II: 1. (10 pts) Write a program that prompts the user to enter the exchange rate from currency US dollars to Chinese RMB. Prompt the u

4、ser to enter 0 to convert from US dollars to Chinese RMB and 1 vice versa. Prompt the user to enter the amount in US dollars or Chinese RMB to convert it to Chinese RMB or US dollars, respectively. Here are the sample runs:Enter the exchange rate from dollars to RMB: 6.81Enter 0 to convert dollars t

5、o RMB and 1 vice versa: 0Enter the dollar amount: 100$100.0 is 681.0 YuanEnter the exchange rate from dollars to RMB: 6.81Enter 0 to convert dollars to RMB and 1 vice versa: 1Enter the RMB amount: 1000010000.0 Yuan is $1468.432. (10 pts) Write a program that prompts the user to enter an integer. If

6、the number is a multiple of 5, print HiFive. If the number is divisible by 2 or 3, print Georgia. Here are the sample runs:Enter an integer: 6GeorgiaEnter an integer: 15HiFive GeorgiaEnter an integer: 25HiFive Part III: Multiple Choice Questions: (1 pts each)(Please circle your answers on paper firs

7、t. After you finish the test, enter your choices online to LiveLab. Log in and click Take Instructor Assigned Quiz. Choose Quiz1. You have 5 minutes to enter and submit the answers.)1. The expression (int)(76.0252175 * 100) / 100 evaluates to _.a. 76b. 76.0252175c. 76.03d. 76.02#2. What is y after t

8、he following switch statement? int x = 0; int y = 0; switch (x + 1) case 0: y = 0; case 1: y = 1; default: y = -1 a. 2b. 1c. 0d. -1#3. Assume x is 0. What is the output of the following statement?if (x 0) System.out.print(x is greater than 0);else if (x 3) ? 2 : 3;a. 5b. 2c. 3d. 4#7. Analyze the fol

9、lowing code. int x = 0; if (x 0); System.out.println(x); a. The value of variable x is always printed.b. The symbol x is always printed twice.c. The symbol x is always printed.d. Nothing is printed because x 0 is false.#8. To declare a constant MAX_LENGTH inside a method with value 99.98, you writea

10、. final double MAX_LENGTH = 99.98;b. double MAX_LENGTH = 99.98;c. final MAX_LENGTH = 99.98;d. final float MAX_LENGTH = 99.98;#9. Which of the following is a constant, according to Java naming conventions?a. readb. MAX_VALUEc. ReadIntd. Test#10. What is y after the following switch statement is execu

11、ted?x = 3;switch (x + 3) case 6: y = 0; case 7: y = 1; default: y += 1;a. 1b. 4c. 3d. 2e. 0#11. Which of the following code displays the area of a circle if the radius is positive.a. if (radius = 0) System.out.println(radius * radius * 3.14159);d. if (radius 0) System.out.println(radius * radius * 3

12、.14159);Solution:Part I:08.06false16943943 is odd0Part II:1.import java.util.Scanner;public class Exercise3_31 public static void main(String args) Scanner input = new Scanner(System.in);System.out.print(Enter the exchange rate from dollars to RMB: ); double rate = input.nextDouble(); System.out.pri

13、nt(Enter 0 to convert dollars to RMB and 1 vice versa: ); int conversionType = input.nextInt(); if (conversionType = 0) System.out.print(Enter the dollar amount: ); double dollars = input.nextDouble(); double RMB = dollars * rate; System.out.println($ + dollars + is + RMB + Yuan); else System.out.pr

14、int(Enter the RMB amount: ); double RMB = input.nextDouble(); double dollars = RMB / rate; System.out.println(RMB + Yuan + is + $ + dollars); 2.import java.util.Scanner;public class Test public static void main(String args) Scanner input = new Scanner(System.in); System.out.println(Enter an integer:

15、 ); int number = input.nextInt(); if (number % 5 = 0) System.out.println(HiFive); if (number % 2 = 0 | number % 3 = 0) System.out.println(Georgia); Part III:1. The expression (int)(76.0252175 * 100) / 100 evaluates to _.a. 76b. 76.0252175c. 76.03d. 76.02Key:a#2. What is y after the following switch

16、statement? int x = 0; int y = 0; switch (x + 1) case 0: y = 0; case 1: y = 1; default: y = -1 a. 2b. 1c. 0d. -1Key:d#3. Assume x is 0. What is the output of the following statement?if (x 0) System.out.print(x is greater than 0);else if (x 3) ? 2 : 3;a. 5b. 2c. 3d. 4Key:c#7. Analyze the following cod

17、e. int x = 0; if (x 0); System.out.println(x); a. The value of variable x is always printed.b. The symbol x is always printed twice.c. The symbol x is always printed.d. Nothing is printed because x 0 is false.Key:c#8. To declare a constant MAX_LENGTH inside a method with value 99.98, you writea. fin

18、al double MAX_LENGTH = 99.98;b. double MAX_LENGTH = 99.98;c. final MAX_LENGTH = 99.98;d. final float MAX_LENGTH = 99.98;Key:a#9. Which of the following is a constant, according to Java naming conventions?a. readb. MAX_VALUEc. ReadIntd. TestKey:b#10. What is y after the following switch statement is

19、executed?x = 3;switch (x + 3) case 6: y = 0; case 7: y = 1; default: y += 1;a. 1b. 4c. 3d. 2e. 0Key:d#11. Which of the following code displays the area of a circle if the radius is positive.a. if (radius = 0) System.out.println(radius * radius * 3.14159);d. if (radius 0) System.out.println(radius * radius * 3.14159);Key:d

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

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