# COSC 1046 Assignment #5 solution

\$29.99

Original Work ?

## Description

5/5 - (1 vote)

Part A: This question is to be submitted to the instructor in the form of a Word (or Open Office) document containing the Java code and appropriate screen capture(s) of the output. The file name must be in the form ASSIGN5A_YourName where ‘YourName’ is your last name followed by your first name with no space. Upload the file to CMS.
[15 marks] Given two strings representing numbers of indeterminate length, create a program that provides the sum of two numbers. The program must use Strings to hold the numbers, String methods (like length(), substring(), charAt()…) to manipulate the values, and two different styles of loops (for, while, do-while).
Please enter a number: 123456 Please enter a second number: 789012 Addition: 123456 + 789012 = 912468
Please enter a number: 123456789012345678901234567890 Please enter a second number: 789012345678901234567890123456 Addition: 123456789012345678901234567890 + 009012345678901234567890123456 = 132469134691246913469124691346
Show screen captures for both of the two numbers above plus the following additional two calculations:
918273645546372819 + 2738495061728349
121212121212 + 98989898989898
[10 marks] Problem 5.17, page 194 Use at least two different loops (while, do-while, and for) in your program. Printf can help with the formatting (See section 4.6). Show screenshots for 5, 12, and 15
COSC 1046 (F17) – Introduction to Computer Science
Part B: Write code and test the solutions for the following problems from the textbook. Submit the .java files for each question to CMS. The answers are due on October 30th and the programs are to be demonstrated to the Teaching Assistant (Tim) by November 6th. He will ask questions to make sure you understand the material. (HINT: If you demonstrate your programs before the due date, Tim can give you an opportunity to fix errors and redemonstrate).
[10 marks] Problem 5.21, page 194 Use printf to format the output (Section 4.6)
[15 marks] Problem 5.43, page 199 Make three versions of this program – one demonstrating the use of each of the loops styles (FOR, WHILE and DO…WHILE).