Long Integer Addition

Can you please type this out and in java? thank you!

For this assignment you are to write a class that supports the addition of extra long integers, by using linked-lists. Longer than what is supported by Java’s built-in data type, called long.

Your program will take in two strings, consisting of only digits, covert each of them to a linked-list that represents an integer version on that string. Then it will create a third linked-list that represents the sum of both of the linked lists. Lastly, it will print out the result of the sum.

Conceptual Example
For the string: “12”, create a list: head->1->2->null
For the string: “34”, create a list: head->3->4->null
Add the two lists to create a third list: head->4->6->null
print the resulting linked list as “46”
Where “->” represents a link.

Keep in mind that the conceptual example above is conceptual. It does suggest a certain implementation. However as you read on you will see that you have several options for implementing your solution. You need not use the suggested implementation above.

For this class you are to implement a minimum of three methods. They are:

A method called makeSDList() that takes in a string, consisting only of digits, as an argument, and creates and returns a linked-link representation of the argument string.

The method has the following header:

SDList makeSDList(String s) { }

where s is a string, and SDList is the class name of the linked list. 

A method called addLists() that takes takes two lists, adds them together, and creates and returns a list that represents the sum of both argument lists.

The method has the following header:

SDList addLists(SDList c) { }

wherec  linked-list of type SDList .

A method called displayList() that takes takes a list, prints the value of each digit of the list. 

The method has the following header:

void displayList() { }

Programming Notes

You need not add any methods you don’t need.
You can add any methods use wish.
You can use any type of linked list like: singly-linked, doubly-linked, circular, etc.
You can choose you own list implementation such-as with or without sentinels, with head and/or tail points, etc.
Do not assume any maximum length for either addend.
You can assume that an each addend is a least one digit long.
You need not test for the null or empty string (“”) cases.
The addends need not be the same length.
Programming Rules:

You are not allowed to change the signature of the three methods above.
You are not allowed to use arrays or ArrayLists anywhere in your solution.
You are not allowed to use any Java built-in (ADTs), such as Lists, Sets, Maps, Stacks, Queues, Deques, Trees, Graphs, Heaps, etc. Or make any class that inherits any of those ADTs.
You are to create your own node and list class. For your node and list class you can use the code that was used in the book, video and lecture notes related to the node and lists class examples.
You are only allowed to have one class for your nodes and one class for your lists.
You are not allowed to use Java Generics.
You can use any data type to represent the digits (in the node). However, each node must represent one and only one digit.
If hard-coding detected in any part of your solution your score will be zero for the whole assignment.
Submission Rules:

1. Submit only one Homework5.java file for all test cases. The starter file is names Homework5a.java so you will need rename the file before you begin submitting your solution.

2. Anything submitted to Mimir is considered to be officially submitted to me and is considered to be 100% your work. Even if it is not your last planned submission.

3. Any extra testing code that you wrote and used to do your own testing should be deleted from the file that gets used in the final grading. I emphasize the word deleted. Commenting out code is not sufficient and not considered deleted. It must be completely removed. English comments written to explain your code are perfectly fine.

Please use starter code:

import java.util.Scanner; // Import the Scanner class

public class Homework5a {
 
public static void main(String[] args) {
SDList x, y, z;
String a, b;
Scanner input = new Scanner(System.in); // Create a Scanner object
System.out.print(“A: “);
a = input.nextLine();
x = makeSDList(a); // convert first string to a linked list
x.displayList(); // call function that displays list x
System.out.print(“B: “); 
b = input.nextLine();
y = makeSDList(b); // convert second string to a linked list
y.displayList(); // call function that displays list z
z = x.addLists(y); // add lists x & y and store result in list y
System.out.print(“A+B: “);
z.displayList(); // call function that displays list z
}

public static SDList makeSDList(String s) {
// put your solution here
return null;
}
}

class SDList {
// put your solution here
 
public SDList addLists(SDList c) { 
// put your solution here
return null; //replace if necessary
}
 
public void displayList() {
// put your solution here
}
}

 

“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

The post Long Integer Addition first appeared on Homework Handlers.


Long Integer Addition was first posted on October 10, 2020 at 12:21 pm.
©2019 "Essay Lords | Bringing Excellence to students world wide". Use of this feed is for personal non-commercial use only. If you are not reading this article in your feed reader, then the site is guilty of copyright infringement. Please contact me at support@essaylords.us

Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic Guarantees
  • Free title page and bibliography
  • Free unlimited revisions
  • Plagiarism-free papers
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Progressive delivery
  • Plagiarism report
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double or single line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Writing quality papers is a TOP priority. One expert takes one order at a time.
The service package includes topic brainstorm, research, drafting, proofreading, plagiarism check, citation formatting, and revisions.

Money-back guarantee

We appreciate how valuable your time is. Hence, we make sure all custom papers are 100% original and delivered within the agreed time frame

Read more

Zero-plagiarism guarantee

Each paper is written from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

We see it as our duty to follow all instruction the client provides. If you feel the completed paper does not meet your exact requirements, we will revise the paper if you let us know about the problem within 14 business days from the date of delivery.

Read more

Privacy policy

Your email is safe, we use your personal data for legal purposes only and in accordance with personal data protection law. Your payment details are also secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

You can easily contact us with any question or issues you need to be addressed. Also, you have the opportunity to communicate directly with assigned writer, e-mail us, submit revision requests, chat with us online, or call our toll-free on our site. We are always available to our customers.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
-->