1. Write a structured program that accepts two integer numbers up to 40 digits and perform...
Fantastic news! We've located 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 topdown 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 submethods. Incomplete java code will not be marked. You will be marked based on correctness and quality of your code. 3. Write a lowlevel 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 lowlevel 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 caseinsensitive
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

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

A strain of Ecoli Beu 397recA441 is placed into a nutrient broth at 30° Celsius and allowed to grow. The data shown in the table are collected. The population is measured in grams and the time...

For the problem specified in the table, build upon the results of the original problem to determine the minimum factor of safety for fatigue at point A, based on infinite life. If the life is not...

Provide the formula for each of the following ionic compounds. (a) Cuprous iodide (b) Ferric nitride (c) Cobaltous phosphate (d) Stannic hypochlorite.

Find the response for the state machine diagram in Figure 638 to the following sequence of inputs (assume that the initial state is STA): Figure 638 W: 0 X: 1 Y: 0 State: STA Z: 1 1 1 1 0 0 0 0 1 1...

Attendance at Orlandos newest Disneylike attraction, Lego World, has been as follows: Compute seasonal indices using all of thedata. GUESTS ON THOUSANDS) GUESTS QUARTER Winter Year 1 Spring Year 1...

For the circuit below derive the transfer function Select one: Ob. O C. d. 10s+2 10s+1 5s+2 5s+1 10s+1 10s+2 5841 5s+2 V,(s) 10F HE 10 10F wwwww V,(s) V2(s) V1(s)

The Financial Advisor is a weekly column in the local newspaper. Assume you must answer the fol lowing question. "I need a new car that I will keep for 4 years. I have three options. I can (A) pay...

Question 3 At 1 October 2019 Mint Ltd had a 70 % holding in Oreo Ltd as well as a number of other small investments. Mint Ltd measures all goodwill and noncontrolling interests using the...

Tusio Ltd manufactures mobile telephones. The current operating level is 400,000 phones but full capacity is 550,000. The phones normally sell for Sh 1,500 per phone. Manufacturing cost data of...

Consider the following example of trying to find the shortest path from S to G in the following graph: (8) H (7) 16 1 (5) J (5) 15 20 5 1 (4) 10 B (6) 7 (3) 11 11 (3) K F (3) 3 (5) 16 20 13 E (3) 19...

When Cassandra started at Jetson Furniture Group, she was told that all employees who bring in new ideas that help the company shave production costs receive a bonus at the end of the year. What does...

Determine the flowrate through the submerged orifice shown in the figure below if the contraction coefficient is C 0.63 Q= i 7 ft3/s 4ft 3in diameter T 2ft 6ft

1) Check whether the following functions are concave, convex, strictly concave, strictly convex, or neither: a) z = x b) z = x + 2x c) z = (x+x)(x + x) 2) Are the following functions quasiconcave...

How to solve the following: In a macroeconomic model, C(t), 1(t) and Y(t) denote respectively the consumption, investment and national income in a country at time t. Assume that for all t: (): C(t) +...

Halley's comet travels in an ellipti cal orbit with a = 17.95 and b = 4.44 and passes by Earth roughly every 76 years. Note that each unit represents one astronomical unit, or 93 million miles. The...

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?

Explain why the percent of molecules that dissociate into atoms in reactions of the type I 2 (g) 2 I(g) always increases with an increase in temperature.

1.00 g each of CO, H 2 O, and H 2 are sealed in a 1.41 L vessel and brought to equilibrium at 600 K. How many grams of CO 2 will be present in the equilibrium mixture? CO(g) + HO(g) = CO(g) CO(g) +...

1.10 g of an unknown compound reduces the freezing point of 75.22 g benzene from 5.53 to 4.92C. What is the molar mass of the compound?
Question Categories