java无忧网
标题: 英文作业:对字符串进行处理 实现两个数正整数相加 [打印本页]
作者: java无忧网 时间: 2018-11-23 11:20
标题: 英文作业:对字符串进行处理 实现两个数正整数相加
Assignment #9
Goals:
Ø This lab gives students more experience in
· Top-down design.
· Procedural abstraction using methods.
· Good style programming.
Requirement
Write a structured program that can accept two integer numbers up to 40 digits and perform the followings:
1. Add the two numbers and display the result.
2. The result number should be separated by commas.
For example
If inputs are:
Number1: 236598745632
Number2: 2453254365546764765
The output should be:
236,598,745,632 +
2,453,254,365,546,764,765
-------------------------------------
2,453,254,602,145,510,397
Notes:
· You must read the two input numbers as string objects, then verify if the input is correct (i.e. all digit characters).
· You may assume that your program only works for positive integer numbers.
· You cannot use any of BigDecimal / BigInteger / double / long / int types for your calculations.
Marking Scheme
[2 marks] Presentation/Style: Organization, readability, descriptive identifier,
indentation, bracket placement
[14 marks] Correctness: Program works without bugs. Appropriate use of
methods.
[4 marks] Internal Documentation and External document (Provide pseudo code
for the method which adds the two String umbers)
运行效果:
下载地址:
**** 本内容需购买 ****
| 欢迎光临 java无忧网 (http://www.javawyw.com/) |
Powered by Discuz! X3.2 |