1. Write a structured program that accepts two integer numbers up to 40 digits and perform...
Fantastic news! We've Found the answer you've been seeking!
Question:
![1. Write a structured program that accepts two integer numbers up to 40 digits and perform the followings:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/08/64edb4e0ac98e_1693299933737.jpg)
![Hello Java 1.8 This is class CPSC1150, This class is one of the best. The output file must be like: 1, 3, 2](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2023/08/64edb4e94794f_1693299944097.jpg)
Transcribed Image Text:
1. Write a structured program that accepts two integer numbers up to 40 digits and perform the followings: Add the two numbers and display the result. For example, You must read the two input numbers as string objects. You may assume that your inputs are valid strings and your program only works for positive integer numbers. You cannot use any of BigDecimal / BigInteger / double / long / int types for your calculations. The result number should be separated by commas. For example If inputs are: If the first input is 236598745632 and the second input is 2453254365546764765, your program must calculate 2453254602145510397 o The output should be: Note: Number1: 236598745632 Number2: ● 1. Now, write a new version by modifying the above program that takes the name of a text file from user and finds the summation of all the numbers in the file. Each line of file represents a big integer. The following shows a sample of the input file: 87345678901234567890 908763456890340 98765432123456789098 45678765432123345560345 1900000000000000014 600000789540002364 ● 2453254365546764765 236,598,745, 632 + 2,453, 254, 365, 546,764, 765 2,453, 254, 602, 145, 510,397 We don't know how many lines are in the file. The final result must be printed in another text file named "result.txt" Use top-down design to write your program 2. Develop body of the method stat (String inFilename, String out Filename) that takes two strings as arguments, and calculates statistics about the input file named inFilename, and writes them into the output file named outFilename. The statistics are line number, number of tokens in the line and number of digits used in the line, separated by comma. For example, if the input file includes the following line: Hello Java 1.8 This is class CPSC1150, This class is one of the best. The output file must be like: 1, 3, 2 2, 4, 4 3, 7, 0 Because in line 1, there are 3 tokens, and 2 digits used In line 2, there are 4 tokens and 4 digits is used in the line. Finally, line 3 includes 7 tokens but no digit. Note: 4. Split your method into sub-methods. Incomplete java code will not be marked. You will be marked based on correctness and quality of your code. 3. Write a low-level algorithm in pseudo code that takes an array of characters that represents a positive double number, and finds its numerical value. (Do not validate the input). ● Notes: ● ● For examples: for the array equal to {'3', '5', '0', '.', '2', '8'} the algorithm should finds its numerical value which is equal to 350.28 Note: for the array equal to {'1', '2', '0', '8', '.', '8'} the algorithm should finds its numerical value which is equal to 1208.8 This is a low-level algorithm, and you should show details of your work. The result is numerical, not string. Your answer will not be marked if you use any java code/method such as ParseDouble (). Write a method in java that given 2 Strings as its parameter, if returns true if all the characters of second parameter is in the first parameter. Otherwise it returns false. For examples: if str1="Test" and str2="See" the result is false. if str1="Police" and str2="Oil" the result is true. if str1="Stamp" and str2="sample" the result is false. if str1="teas" and str2="seats" the result is false. The order of letters is not a problem. The method is case-insensitive 1. Write a structured program that accepts two integer numbers up to 40 digits and perform the followings: Add the two numbers and display the result. For example, You must read the two input numbers as string objects. You may assume that your inputs are valid strings and your program only works for positive integer numbers. You cannot use any of BigDecimal / BigInteger / double / long / int types for your calculations. The result number should be separated by commas. For example If inputs are: If the first input is 236598745632 and the second input is 2453254365546764765, your program must calculate 2453254602145510397 o The output should be: Note: Number1: 236598745632 Number2: ● 1. Now, write a new version by modifying the above program that takes the name of a text file from user and finds the summation of all the numbers in the file. Each line of file represents a big integer. The following shows a sample of the input file: 87345678901234567890 908763456890340 98765432123456789098 45678765432123345560345 1900000000000000014 600000789540002364 ● 2453254365546764765 236,598,745, 632 + 2,453, 254, 365, 546,764, 765 2,453, 254, 602, 145, 510,397 We don't know how many lines are in the file. The final result must be printed in another text file named "result.txt" Use top-down design to write your program 2. Develop body of the method stat (String inFilename, String out Filename) that takes two strings as arguments, and calculates statistics about the input file named inFilename, and writes them into the output file named outFilename. The statistics are line number, number of tokens in the line and number of digits used in the line, separated by comma. For example, if the input file includes the following line: Hello Java 1.8 This is class CPSC1150, This class is one of the best. The output file must be like: 1, 3, 2 2, 4, 4 3, 7, 0 Because in line 1, there are 3 tokens, and 2 digits used In line 2, there are 4 tokens and 4 digits is used in the line. Finally, line 3 includes 7 tokens but no digit. Note: 4. Split your method into sub-methods. Incomplete java code will not be marked. You will be marked based on correctness and quality of your code. 3. Write a low-level algorithm in pseudo code that takes an array of characters that represents a positive double number, and finds its numerical value. (Do not validate the input). ● Notes: ● ● For examples: for the array equal to {'3', '5', '0', '.', '2', '8'} the algorithm should finds its numerical value which is equal to 350.28 Note: for the array equal to {'1', '2', '0', '8', '.', '8'} the algorithm should finds its numerical value which is equal to 1208.8 This is a low-level algorithm, and you should show details of your work. The result is numerical, not string. Your answer will not be marked if you use any java code/method such as ParseDouble (). Write a method in java that given 2 Strings as its parameter, if returns true if all the characters of second parameter is in the first parameter. Otherwise it returns false. For examples: if str1="Test" and str2="See" the result is false. if str1="Police" and str2="Oil" the result is true. if str1="Stamp" and str2="sample" the result is false. if str1="teas" and str2="seats" the result is false. The order of letters is not a problem. The method is case-insensitive
Expert Answer:
Answer rating: 100% (QA)
1 Write a structured program that accepts two integer numbers up to 40 digits and performs addition The input numbers are read as strings and the resu... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
. A spring scale reads 2 0 N as it pulls a 5 . 0 kg mass across a table. What is the magnitude of the force exerted by the mass on the spring scale?
-
Preferred stock is an example of a (n): Select one: O a. perpetuity O b. ordinary annuity O c. early annuity O d. annuity due O e. inventory accounting method O f. pure discount loan Check
-
(1) (a) Discretize the 2D Poisson equation Vu(x, y) = Uxx + Uyy = = p(x, y) with second-order accurate central differences with Ax = the given charge density. Ay=h. p(x, y) is (b) Express uij in...
-
Given the following data about XYZ Mutual Fund on Oct. 1: Assets: Liabilities: Cash = $40,000 Accrued fees and expenses = $5,000 1,000 Shares of Stock A: Closing Price $30 2,000 Shares of Stock B:...
-
Considering the different tasks a salesperson must perform how is the job different for an automobile salesperson and a representative selling a computer system?
-
Each of the matrices in Problem is the final matrix form for a system of two linear equations in the variables x 1 and x 2 . Write the solution of the system. -2
-
What important criteria should be used to determine whether a sponsor can help the organization through the planned change? AppendixLO1
-
How is an organization like an iceberg? Use the iceberg metaphor to describe the field of organizational behavior.
-
Flight Caf prepares in-flight meals for airlines in its kitchen located next to a local alrport. The company's planning budget for July appears below: Flight Caf Planning Budget For the Month Ended...
-
George Pharmacy is a pharmaceutical salesman who has been very successful at his job in the last few years. Unfortunately, his family life has not been very happy. Three years ago, his only child,...
-
Etson Canada designs, manufactures, and supports printing machines for industrial applications. After about 10 years in this industry, the firm has decided to pursue its long-term goal of expansion...
-
A storeroom is used to organize items stored in it on N shelves. Shelves are numbered from 0 to N-1. The K-th shelf is dedicated to items of only one type, denoted by a positive integer A[K]....
-
CASES CASE 10.1 Money in Motion Jake Nguyen runs a nervous hand through his once finely combed hair. He loosens his once perfectly knotted silk tie. And he rubs his sweaty hands across his once...
-
(3.8) Axiom, Definition of false false = true (3.9) Axiom, Distributivity of over : (pq) p=q
-
The board of directors of Unilever has been impressed by the presentation you did, and they further instructed you to conduct a more insightful investigation about the Sri Lankan market. They have...
-
The sample space listing the eight simple events that are possible when a couple has three children is {bbb, bbg, bgb, ogg, gbb, gbg, ggb, ggg}. After identifying the sample space for a couple having...
-
Harrimon Industries bonds have 4 years left to maturity. Interest is paid annually, and the bonds have a $1,000 par value and a coupon rate of 9%. What is the yield to maturity at a current market...
-
Write a paper about how diet relates to breast cancer in women study design to use: case control study purpose & rationale the purpose of this final project is to utilize the methods and...
-
Describe the two ways in which control statements can be combined.
-
Determine whether each of the following is true or false. If false, explain why. a) A single array can store values of many different types. b) An array index should normally be of type float. c) An...
-
How does the .NET Framework Class Library facilitate the development of .NET apps?
-
14. Assume in problem 12 that the city reports the work as a capital asset. Which ofthe following is true? a. Depreciation is not recorded because the city has no cost. b. Depreciation is not...
-
7. Which of the following is true for the Year 2 government-wide financial statements? a. Both expense and liability will be zero. b. Both expense and liability will be $110,000. c. Expense will be...
-
10. What liability should the city report on government-wide financial statements at the end ofYear 1? a. It depends on whether the employees work at governmental activities or business-type...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App