云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > JAVA实验指导书-实验一

JAVA实验指导书-实验一

  • 62 次阅读
  • 3 次下载
  • 2025/5/26 5:24:20

Develop a program that prints a tax table for taxable income from $50,000 to $60,000 with intervals of $50 for all four statuses, as follows:

写一个计程序,打印应纳税所得税表从50000美元到60000美元的所有四个状态的50个区间

taxable Income

50000 50050 ... 59950 60000

Single Married Married Head of Joint Separate a House 9846 9859

7296 7309

10398 8506 10411 8519

12532 9982 13190 11192 12546 9996 13205 11206

NOTE: the numbers in the preceding tax table are incorrect intentionally. You should print the correct values in the table.

Submit the following items:

1. Analysis: Restate the problem in your own words (e.g., what is input, output if

any, what needs to be computed, what data needs to be stored and their type).

2. Design: Clearly describe the steps to solve this problem using English or pseudo

code.

3. Coding: Implement the solution in Java.

4. Testing: Submit the screen shots for first 20 lines in the tax table. 4.测试:在税收表中提交前20行的屏幕截图。

5

Project #3 Least Common Multiple (covers Chapter 5)

CSCI 1301 Introduction to Programming Armstrong Atlantic State University

Definition: The least common multiple (LCM) of two numbers is the smallest number that is a multiple of both. For example, the LCM for 8 and 12 is 24, for 15 and 25 is 75, and for 120 and 150 is 600.

Develop a program that prompts the user to enter two integers and finds their least common multiple.

开发一个程序,提示用户输入两个整数,并找到它们的最小公倍数。

To find the LCM of two numbers, first create a prime factor table for each number. The first column of the table consists of all the prime factors and the second column tracks the occurrence of the corresponding prime factor in the number. For example, the prime factors for 120 are 2, 2, 2, 3, 5, so the prime factor table for number 120 is shown as follows:

prime factors for 120 # of occurrence 2 3 3 1 5 1 table[0][0] = 2 table[0][1] = 3 table[1][0] = 3 table[1][1] = 1 table[2][0] = 5 table[2][1] = 1

The prime factors for 150 are 2, 3, 5, 5, so the prime factor table for number 150 is shown as follows:

prime factors for 120 # of occurrence 2 1 3 1 5 2 table[0][0] = 2 table[0][1] = 1 table[1][0] = 3 table[1][1] = 1 table[2][0] = 5 table[2][1] = 2

The LCM of the two numbers consists of the factors with the largest occurrence in the two numbers. So the LCM for 120 and 150 is 2?2?2?3?5?5, where 2 appears three times in 120, 3 one time in 120, and 5 two times in 150.

Submit the following items:

1. Analysis: Restate the problem in your own words (e.g., what is input, output if

any, what needs to be computed, what data needs to be stored and their type). 2. Design: Clearly describe the steps to solve this problem using English or pseudo

code. (Hint: The prime factor table can be represented using a two-dimensional array. Write a method named getPrimeFactors(int number) that returns a two-dimensional array for the prime factor table.)

(提示:可以使用一个二维数组表示素因子表。写一个方法叫getprimefact OR(int数),返回的素因子表的二维数组。)

3. Coding: Implement the solution in Java.

4. Testing: Test your program to find the LCM for (120, 150), (7, 14), (7, 8), (1, 2),

and (345, 455)

6

Project #4 Design Classes (covers Chapter 6)

CSCI 1302 Introduction to Programming Armstrong Atlantic State University

This project consists of two separate problems.

1. Design a class named Rectangle to represent a rectangle. The class contains: ? Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. ? A string data field named color that specifies the color of a rectangle.

Hypothetically, assume that all rectangles have the same color. The default color is white. ? A no-arg constructor that creates a default rectangle.

没有参数的构造函数,创建一个默认的矩形。

? A constructor that creates a rectangle with the specified width and height.

创建一个具有指定宽度和高度的矩形的构造函数

? The accessor and mutator methods for all three data fields.

所有三个数据字段的访问器方法。

? A method named getArea() that returns the area of this rectangle.

一种getarea()返回这个矩形的面积。

? A method named getPerimeter() that returns the perimeter.

一种getperimeter()返回周长。

Draw the UML diagram for the class. Implement the class.

这类画UML图。实现类。

Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perimeters.

编写一个创建两个矩形对象的测试程序。分配宽度4和高度40到第一个对象和宽度3.5和高度35.9到第二个对象。将颜色分配给所有矩形对象。 显示的对象的属性,找到他们的周长和面积。

2. Design a class named Time. The class contains:

? Data fields hour, minute, and second that represents a time. ? A no-arg constructor that creates a Time object for the current time. (The data fields value will represent the current time)

在没有参数的构造函数中创建时间为当前时间对象.(数据值将代表当前时间) ? A constructor that constructs a Time object with a specified elapse time since the middle night, Jan 1, 1970 in milliseconds. (The data fields value will represent this time)

一个构造函数构造一个时间与指定的时间从半夜对象,1970年1月1日在毫秒。(数据字段值将代表这段时间)

7

? Three get methods for the data fields hour, minute, and second, respectively.

Draw the UML diagram for the class. Implement the class. Write a test program that creates two Time objects (using new Time() and new Time(555550000)) and display their hour, minute, and second.

这类画UML图。实现类。写一个测试程序,创建两个时间对象(使用新的time()和 新时期(55555 0000)),显示小时,分钟和秒。

Hint: The current time can be obtained using System.currentTime(), as shown in Listing 2.8, ShowCurrentTime.java. The other constructor sets the hour, minute, and second for the specified elapse time. For example, if the elapse time is 555550000 milliseconds, the hour is 10, the minute is 19, and the second is 10.

提示:当前时间可以通过使用System.currenttime(),如Listing2.8所示,

ShowCurrentTime.java。其他构造函数设置小时,分钟和第二的指定时间。 例如,如果过去的时间是55555的0000毫秒,时间是10分钟,这是19,第二是10。

附件二:

北京邮电大学软件学院

实验报告

课程名称: Java SE程序设计

项目名称: Java编程(基础练习)

项目完成人:

姓名:________学号:________ 姓名:________学号:________ 姓名:________学号:________ 姓名:________学号:________ 姓名:________学号:________

指导教师:__________________

8

搜索更多关于: JAVA实验指导书-实验一 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

Develop a program that prints a tax table for taxable income from $50,000 to $60,000 with intervals of $50 for all four statuses, as follows: 写一个计程序,打印应纳税所得税表从50000美元到60000美元的所有四个状态的50个区间 taxable Income 50000 50050 ... 59950 60000 Single Married Married Head of Joint Separate a House 9846 9859 7296 7309 10398 8506 10411 8519 1

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com