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:
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:...
-
The Meerwein?Ponndorf?Verley reaction involves reduction of a ketone by treatment with an excess of aluminum triisopropoxide. The mechanism the process is closely related to the Cannizzaro reaction...
-
Show how Novocain®, a painkiller used frequently by dentists (Section 30.3), can be prepared from benzene. CH,CH CH2CH2O NH, CH,CH2 Novocain
-
Explain why composition of the Board of Directors is important.
-
Heather wants to invest $40,000 in a relatively safe venture and has discovered two alternatives that would produce the following ordinary income and loss over the next three years: She is interested...
-
12. If the velocity-time graph has the shape AMB, what would be the shape of the corresponding acceleration-time graph? (A) a (B) (C) A (D) a A M B time(t)
-
Use a time series chart to display the data shown in the table. The table represents the percentages of the U.S. gross domestic product (GDP) that come from the manufacturing sector. Organize the...
-
In the confrontation between Georgia and the Supreme Court over Cherokee Removal, who won? Based upon the Court's decisions in the Cherokee cases, what became evident concerning the role of the...
-
A supply chain consists of three partners: the focal OEM with significant bargaining power and two smaller partners, an upstream supplier and a downstream retailer. Each supply chain layer holds some...
-
Explain the role of logistics in a modern economy.
-
What are the distinctive features of cost management when compared to cost accounting? Name and describe the three key focus areas of cost management.
-
Explain the concept of insurance as a typical risk transfer strategy.
-
Explain how financial performance and operating performance differ in a supply chain.
-
Gap has started selling through its online channel along withits retail stores. Management has to decide which products to carryat the retail stores and which products to carry at a central warehouse...
-
Integration is a vital concept when applied in one?s life. Integrating your life means making ideal choices. Perfect choices on the other go in line with quality decisions. Quality decisions lead to...
-
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?
-
Aside from Calories, what else do you need to obtain through your diet? (a) a complete protein (b) a complete carbohydrate (c) vitamins and minerals (d) both a complete protein and vitamins and...
-
Trace the path of blood through the body, beginning with blood returning from the tissues to the heart. Be sure to name each of the chambers of the heart.
-
Which blood vessels are responsible for nutrient and waste exchange with tissues?
Study smarter with the SolutionInn App