السلام عليكم ورحمه الله وبركاته
اخواني واخواتي الكرام
مطلوب مني مشروع بسيط
في لغة الجافا
وهو برنامج يقرأ من ملف خارجي
مثلا سطرين في ملف تكست
كل سطر فيه معادلة حسابية
البرنامج يقوم بقراءة المعادلات ويقوم بحلها
واخراجها في ملف خارجي ثاني
ارجووكم جدا الي عنده فكرة عن كذا لا يبخل علينا جزاكم الله الف خير
هذا المشروع بالتفصيل
اقتباس
SUMMARY:
This project will require you to create a Java program that will take an input fileconsisting of several lines of infix notation mathematical calculations, convert them topostfix notation (using the first algorithm below), and evaluate them (using the secondalgorithm below).The results of the calculations will then be printed to an output file. This project willbuild on your linked list implementations, using them to create your ownimplementations of stacks and queues for each of the algorithms.PROGRAM:1. Input file:The input file will contain several lines of equations in infix format. Each line can useseveral of the available mathematical or logical operators: addition [+], subtraction [-],multiplication [*], division [/], parentheses [()], less than [<], greater than [>], equal to[=], logical AND [&], logical OR [|], and logical NOT [!]. For us, - is a binary operator, so -5is illegal. When using the mathematical and logical operators together, let “false” havevalue 0 and “true” have value 1. Let precedencies be: {*,/} > {+,-} > {=,&,|,!}.For example, an input file could consist of the following lines:4.7 + 3.0 * 5.5 (evaluates to 21.2)(4 > 3) + (3 = 4) + 2 (evaluates to 3)2. Calculator program:For each line of input, your calculator program will begin by converting from infixnotation to postfix notation. Infix notation, shown in the example input lines above, isthe standard representation of mathematical equations. Postfix, or Reverse Polishnotation, is a mathematical notation where the mathematical operator comes afterboth its operands. The two input lines in postfix notation would be:4.7 3.0 5.5 * +4 3 > 3 4 = + 2 +The main parts of the calculator program are:• Converting an input line into a postfix expression:This step will use both a stack and queue in order to convert expressions from infix topostfix notation. The stack and queue will be implemented by you, using your linked listimplementation from labs (do NOT use the predefined stack/queue classes available inJava). Each value will be read from the input line, and dealt with in the followingmanner:1. If the value is an operand, add it into the queue immediately.2. If the value is a close-parenthesis [‘)’], pop all the stack elements and addthem to the queue one by one until an open-parenthesis [‘(‘] is found.3. If the value is an operator or (, pop everything on the stack and add them tothe queue one by one until you reach either an operator of lower precedence, ora right-associative operator of equal precedence (eg, the logical NOT is a rightassociativeoperator). Add the found operator to the queue, and push theoriginal operator onto the stack.4. At the end of the input, pop everything that remains on the stack and add tothe queue one by one.• When finished converting one statement into a queue in postfix notation, pass thequeue to the next step – the postfix expression evaluator. Evaluating the postfixexpression. This step will use the queue that was the result of the infix to postfixconversion, and a stack.Again, the stack and queue will be implemented by you, using your linked listimplementation from labs (do NOT use the predefined stack/queue classes available inJava). The algorithm proceeds as follows:1. Get the element at the front of the queue.2. If the value is an operand, push it onto the stack.3. If the value is an operator, pop the appropriate number of operands from thestack (eg. 2 operands for multiplication, 1 for logical NOT). Perform theoperation, and push the resulting value onto the stack.• Repeat steps 1-3 until the queue is empty. When it is, there should be a single value inthe stack – that value is the result of the calculation.3. Output file:For each calculation, print the result of the calculation to an output file, with onenumerical result per line.
