Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Write a structured program that accepts two integer numbers up to 40 digits and perform the followings: Add the two numbers and display
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
Step by Step Solution
★★★★★
3.38 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started