Write a program for a calculator

Assignment Help Programming Languages
Reference no: EM13333090

Write a program for a Calculator that can do two operations, + and -. This calculator should be able to add or subtract two numbers of any size. You may use Recursion if you want. The following is the sequence of steps that your program should follow:

1. Ask user to enter the first number.

2. Your program should get this number from the user.

3. Ask user to enter the second number.

4. Your program should get this number from the user.

5. Ask user whether the user wants addition or subtraction. User will enter + or -.

6. Your program should add or subtract the two numbers depending on what user entered above.

7. Finally, your program should show the result in the output screen.

Now, in order to implement this calculator program, you need to remember the following:

1. Take the first number from the user and store that number in a linked list. Let's say the first linked list has head named ‘num1'.

2. Take the second number from the user and store it in another linked list. Let's say the second linked list has head named ‘num2'.

3. Remember that the user may enter a number of any size. Your program should keep on taking the number until user hits the Enter key. As soon as the user hits Enter key, your program should know that the user is done entering the first number. Now your program should repeat this process to take second number from the user.

4. If the user enters the following number: 45683450976535456 and hits Enter, it means your code should create the first linked list of 17 nodes because there are 17 digits in the abovementioned number. Similarly your program will create another linked list of n nodes where n is the number of digits in the second number.

5. Let's say, the user enters 351278 as the first number and 21 as the second number. So after taking both numbers from the user, this will be the situation:

1396_assign 1.png

6. Now if user entered +, then all you need to do is to add the above two linked list and create a third linked list containing the final answer. Print this linked list in the output screen.

552_assign 2.png

Reference no: EM13333090

Questions Cloud

The calcium hydride reacts with water to form hydrogen gas : Calcium hydride (CaH_2) reacts with water to form hydrogen gas. How many grams of CaH_2 are needed to generate 55.0 L of H_2 gas at a pressure of 0.995 atm and a temperature of 32 degrees Celsius
Software and marketing are currently out selling km solutio : Watch the KM Promo videos to get an idea of what software and marketing are currently out selling KM solutions
What is the profit-maximizing output for the monopolist : What is the profit-maximizing output for the monopolist? Calculate its profit.
Determine the pressure in the narrow section of the pipe : An incompressible fluid is flowing through a pipe with a constriction. The pipe is on an incline with an angle of 30.0 degrees. What is the pressure in the narrow section of the pipe
Write a program for a calculator : Write a program for a Calculator that can do two operations, + and -. This calculator should be able to add or subtract two numbers of any size. You may use Recursion if you want.
Development of assumptions and plans : Development of assumptions and plans about the factors influencing next year's budget in advance of the budget year starting and approval of the budget before the commencement of the budget year
Calculate book and market values of firms stockholder firm : Ez toy inc. lists fixed assets of $25 million on its balance sheet. The firm's fixed assets were recently appraised at $32 million. EZ toy inc's balance sheet also lists current assests at $10 million.
Obtain the magnitude of the induced current in the coil : The component of the external magnetic field along the central axis of a 125-turn coil of radius 29.0 cm decreases from 2.90 T to 0.400 T in 2.40 s. what is the magnitude of the induced current in the coil
What will be their wacc if they incerase debt as proposed : A company is trying to decide whether to revise its target capital structure. Currently, it targets 50% debt and 50% equity. However, it is considering changing the mix to 70% debt and 30% equity.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write program to compute diameter in centimeters

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  What is the height of the retinal image

Create a binary image at least 64x64 in dimensions. Using Octave's existing functions, perform Average, Gaussian and Laplacian filters on the image. Display the original image and each of the filtered images in Octave plots. Discuss and compare your..

  Design classes account-checkingaccount and savingsaccount

Design and write 3 classes - Account, CheckingAccount, and SavingsAccount. Have CheckingAccount and SavingsAccount inherit from Account.

  Show tic-tac-toe game scenario diagram

The assignment is not to implement this game in Ruby. Rather, the assignment is to use scenario diagrams to discover the objects, their responsibilities, and the messages they respond to

  Design bank account class with data members-member functions

Design the Bank Account class with suitable data members and member functions - think of attributes or features of a bank account - think of kind of data (and actions) you require to open account.

  Explaining exception handling using program

Use exception handling appropriately. Use comments to illustrate the various concepts applied / utilized in the solution.

  Write program that compute the amount person earn

Write a program which computes the amount a person would earn over period of time if his or her salary is one penny the first day, two pennies second day.

  Application to simulate functionality of gas-visual basic

Design the application which simulates functionality of gas pump. User enters number of gallons to buy and clicks desired grade (regular special super). Using Visual Basic.

  Program to calculate the electricity bill

Write a program to calculate the electricity bill. The rates of electricity per unit are as follows: If the units consumed are equal or less than 100, then the cost is Rs 8/- per unit.

  Create program which asks for number of fat grams

Create a program which asks for number of fat grams and calories in a food item. Validate input as follows: Make sure number of fat grams and calories are not less than 0.

  Display the property tax for n property owners

Write a java application that calculates and displays the property tax for N property owners. N should be declared as a constant and it should be equal to the largest digit of your student ID number

  Write program which asks user for names

Write down a program which asks user for names (Prompt user with something like "Enter a name, or q when finished"), assigns new Person (in heap memory) for each of them.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd