Question: Introduction to Algorithms Homework 2: MULTI-LINE CALCULATOR In this homework you are going to write a (C/C++) program that will interpret mathematical calculations from an



Introduction to Algorithms Homework 2: MULTI-LINE CALCULATOR In this homework you are going to write a (C/C++) program that will interpret mathematical calculations from an input file with inp" extension. The input file can include keywords, alphanumeric variables, symbols, and operators Each line is taken as an expression. The result of the calculation will be written to an output file without" extension. The program search at the inp" files in the same folder with the executable and create the separate "out" files for each input. You have different challenge steps to interpret the inputs. Solve as much challenge as you can. Do not start form the last one. I strongly advise to solve them one by one. Each time creating a different project should be a good practice. Do not copy pas: your previous solution but use the knowledge from it to solve next challenge. The examples are just informal. Your interpreter must calculate different operation combinations Keywords: OUT, IN, IF, THEN, ELSE, LOOP, TIMES Write out the given variable input in the console and output file. IN Gets input to a variable from console (We do not use in challenges.) Stories on If course. It will followed by THEN and Ease in one line A=IF BC THEN BEESEC OUT OUT A IND IF THEN ELSE LOOP Create a loop that will do the operation between 200P and TIMES keyword LOOP A=3+A TIMESS A times nis given as a constant after IIMES keyword. >,!,!-, * Operations: ../.+, Multiplication / Division Addition Subtraction, Smaller Grater Equality Smaller or Equal >= Grater or Equal 1 Not Not Equal Assignment 52 -> 10 5/2 => 2 50/2 => 25 5+2 -> 7 5-2 => 3 5 false 5 > 2 => true 5= 2 => false, 2-2 => true 562->true, 22 >> true 5 >=2 => true, 2>= 2 => true 15 =>ialse, 10 => true S!- 2 => true. 2 I 2 => false A=5 Symbols: Variable Names: Start with an alphabetic character and can continue with alphanumeric characters. Ex A,B,C,D,E, A1, B2C, C3,D44.. Challange1: Integer Constants one character variable names A-5 (- AB OUTC Output file must store 15 Challange2: Double Constants one-character variable names A - 5.3 0 - 10.2 (-A OUT Output file must store: 15.5 Challange3. Integer Division B-9 - BA OUTC Output file must store: 1 Challenge4: Double Division A - 5.0 B- (-8/A OUTC Output file must store: 1.8 Challanges: Operator Precedence A-6 CAD OBA OUT D Output file must store: 28 Challange6: Operator Precedence with Parentheses 4-1 3 - 2 -AB D( AD) CB OUT O Output file must store. 12 Challange7: using IF THEN ELSE statement AL1 61 = 2 A2 - IF AI > 32 THEY AI ELSE BI ERIT AZ Output file must store 2 Challanges: Combine IF cause with operations A-1 - (A.) - 3 THEN A ELSE OUTC D-2 Output file must store: 1 Challange9: Loop Statement A= B = 3 LOOP-CASTINES 5 OUT Output file must store 30 Challange10: Create your custom input files and try your muito line calculate percrctness Program Main Screen No output will be shown on the screen unless the input file includes an IN command. Your program must start and end without any unnecessary input and output commands. Just the OUT commands from the input file should result a console and file output. IMPORTANT INFO ABOUT HOMEWORK DELIVERY Homework is collected over merger system. Any other delivery method is not going to be accepted. While writing the code, students must obey the rules below. Al the beginning of your code file there must be a comment part giving information about you, compiler environment of your code and any other issue need to be taken into consideration to run the code file. EX // 11 1306XXXXX Date 02.12.2019 // Development Environment Visual Studio2019 The code file should be compiled either in Microsoft Visual Studio or under GOC (Codeblocks is using this also) Onty one code file is collected so do not try to send any other file or more than one file The code file must be named as "1306XXXXXXcpp" with your student number and opp tale extention if your program includes extra beader files such as "stdafx.l" at takes zero since I cannot compile your code. Be careful about it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
