--%>

Learning File system with operations

Program 1. Purpose of this assignment is to learn to work with files.
Assignment: The file, data.txt, is provided on the class website. Each line of the file consists of a binary operator followed by two operands. Your program will read each line and perform the operation described.

Additional requirements:

There are four possible operations, which your program should store: addition, subtraction, multiplication, and division.

  1. Since order matters for subtraction and division, assume that each line is of the form operator,operand1,operand2 and therefore the operation to perform is operand1 operator operand2 = answer For example, if the line is division,4,3 your program should produce 4 / 3 = 1.33 where operator has been replaced by its common symbol.
  2. When the operand is division, the result should be shown to two decimal places if the second operand is not zero. Since division by zero is undefined, report "undefined" when the denominator is 0.
  3. The results should be printed to the screen. For each line in the file there should be one line of output.
  4. Do not hard-code your program to your particular data; we will generate a different data for testing your program. You can assume that each line will have the form described above and that the operands will be integers that can be stored in four bytes.

Sample Output: Here is some sample output to give you an idea of what you are
trying to achieve.
If data.txt is
addition,82,10
subtraction,3,57
multiplication,90,46
division,26,7
division,26,0
then your program would produce
82 + 10 = 92
3 - 57 = -54
90 * 46 = 4140
26 / 7 = 3.71
26 / 0 = undefined operation

   Related Questions in Programming Languages

  • Q : Generating uniform random numbers using

    In .NET, write a simple web service in C# to generate uniform random numbers. Use the class System.Random to generate the random numbers. What part of the code is specifically associated with web services? How could you deploy the web service?

  • Q : Define Zip file Zip file : It is a file

    Zip file: It is a file employed to store compressed versions of the files. In connection with Java bytecode files, such have mostly been superseded by the Java Archive (abbreviated as JAR) files.

  • Q : Functions of states of the

    Mention the different states of the XMLHttpRequest an dalso describe their functions.

  • Q : Define Parallel programming Parallel

    Parallel programming or parrelel computing is the concurrent use of multiple compute resources to resolve a specified problem. Parallel program always comprises of concurrently executing processes, problem decomposition relates to the manner in which

  • Q : Requirement of Timer control in AJAX

    Explain the requirement of a Timer control in the AJAX.

  • Q : Define Factoring Problem Factoring

    Factoring Problem: Factoring is the action of dividing an integer into a set of smaller integers (or factors) which, when multiplied altogether, form the unique integer. For illustration, the factors of 15 are 3 and 5; the factoring trouble is to find

  • Q : Grade someone activities Normal 0 false

    Normal 0 false false

  • Q : Explain Edit-compile-run cycle

    Edit-compile-run cycle: A common portion of the program development procedure. The source file is made initially and compiled. The syntax errors should be corrected in the editor before compiling it again. Once the program has been productively compil

  • Q : Define Unbounded repetition Unbounded

    Unbounded repetition: The repetition where statements in a loop's body are executed an arbitrary number of times, according to the consequences of the statements in the loop's body. All of the loop control structures in the Java offer for unbounded re

  • Q : Define the term Direct recursion Define

    Define the term Direct recursion: Recursion which outcomes from a method of calling itself.