منتدى استراحات زايد

منتدى استراحات زايد (http://vb.ma7room.com/index.php)
-   منتدى أخبار المواقع والمنتديات العربية والأجنبية (http://vb.ma7room.com/forumdisplay.php?f=183)
-   -   [استفسار] اخواني ارجوكم مساعدتكم في لغة java (http://vb.ma7room.com/showthread.php?t=1478744)

محروم.كوم 05-10-2014 04:10 PM

[استفسار] اخواني ارجوكم مساعدتكم في لغة java
 


السلام عليكم ورحمه الله وبركاته
اخواني واخواتي الكرام
مطلوب مني مشروع بسيط
في لغة الجافا
وهو برنامج يقرأ من ملف خارجي
مثلا سطرين في ملف تكست
كل سطر فيه معادلة حسابية
البرنامج يقوم بقراءة المعادلات ويقوم بحلها
واخراجها في ملف خارجي ثاني
ارجووكم جدا الي عنده فكرة عن كذا لا يبخل علينا جزاكم الله الف خير

هذا المشروع بالتفصيل


اقتباس:






SUMMARY:
This project will require you to create a Java program that will take an input file
consisting of several lines of infix notation mathematical calculations, convert them to
postfix notation (using the first algorithm below), and evaluate them (using the second
algorithm below).
The results of the calculations will then be printed to an output file. This project will
build on your linked list implementations, using them to create your own
implementations 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 use
several of the available mathematical or logical operators: addition [+], subtraction [-],
multiplication[*], division [/], parentheses [()], less than [], equal to
[=], logical AND [&], logical OR [|], and logical NOT [!]. For us, - is a binary operator, so -5
is illegal. When using the mathematical and logical operators together, let “false” have
value 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 infix
notation to postfix notation. Infix notation, shown in the example input lines above, is
the standard representation of mathematical equations. Postfix, or Reverse Polish
notation, is a mathematical notation where the mathematical operator comes after
both 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 to
postfix notation. The stack and queue will be implemented by you, using your linked list
implementation from labs (do NOT use the predefined stack/queue classes available in
Java). Each value will be read from the input line, and dealt with in the following
manner:
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 add
them 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 to
the queue one by one until you reach either an operator of lower precedence, or
a right-associative operator of equal precedence (eg, the logical NOT is a rightassociative
operator). Add the found operator to the queue, and push the
original operator onto the stack.
4. At the end of the input, pop everything that remains on the stack and add to
the queue one by one.
• When finished converting one statement into a queue in postfix notation, pass the
queue to the next step – the postfix expression evaluator. Evaluating the postfix
expression. This step will use the queue that was the result of the infix to postfix
conversion, and a stack.
Again, the stack and queue will be implemented by you, using your linked list
implementation from labs (do NOT use the predefined stack/queue classes available in
Java). 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 the
stack (eg. 2 operands for multiplication, 1 for logical NOT). Perform the
operation, 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 in
the 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 one
numerical result per line.



الساعة الآن 03:37 AM

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By Almuhajir


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227