b) You are given a file "input1b.txt". The first line of the input file will contain an integer T, representing the number of test cases. The next T lines will contain a single arithmetic expression. Each arithmetic expression will start with the prefix "calculate". It is guaranteed that the expression will have exactly two operands and one operator. Calculate the result based on the operation (operator) on the operands and for each line of expression, write the result with "The result of $a $operator $b is $result" where $a and $b are the values of the first and second operator respectively, and $operator is the operator and $result is the result of the operation. All the results must be compiled in a single file, "output1b.txt." Sample Input File 15 calculate 67 +41 calculate 85/5 calculate 1356 calculate 99 - 95 calculate 3/10 calculate 12* 19 calculate 14 - 6 calculate 3* 88 calculate 4568 calculate 81-0 calculate 77+ 40 calculate 8 * 84 calculate 73 - 22 calculate 85-86 calculate 28 58 Sample Output File The result of 67 +41 is 108 The result of 85/5 is 17.0 The result of 13-56 is -43 The result of 99 - 95 is 4 The result of 3/10 is 0.3 The result of 12 * 19 is 228 The result of 14 - 6 is 8 The result of 3* 88 is 264 The result of 45* 68 is 3060 The result of 81-0 is 81 The result of 77 + 40 is 117 The result of 8 * 84 is 672 The result of 73-22 is 51 The result of 85-86 is -1 The result of 28 * 58 is 1624

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
b) You are given a file "input1b.txt". The first line of the input file will contain an integer T,
representing the number of test cases. The next T lines will contain a single arithmetic
expression. Each arithmetic expression will start with the prefix "calculate". It is
guaranteed that the expression will have exactly two operands and one operator.
Calculate the result based on the operation (operator) on the operands and for each line
of expression, write the result with "The result of $a $operator $b is $result" where $a
and $b are the values of the first and second operator respectively, and $operator is the
operator and $result is the result of the operation. All the results must be compiled in a
single file, "output1b.txt."
Sample Input File
15
calculate 67 +41
calculate 85/5
calculate 13 - 56
calculate 99 - 95
calculate 3/10
calculate 12* 19
calculate 14 - 6
calculate 3* 88
calculate 45 * 68
calculate 81 - 0
calculate 77 + 40
calculate 8 * 84
calculate 73-22
calculate 85-86
calculate 28 * 58
Sample Output File
The result of 67 +41 is 108
The result of 85/5 is 17.0
The result of 13 - 56 is -43
The result of 99 - 95 is 4
The result of 3/10 is 0.3
The result of 12 * 19 is 228
The result of 14 - 6 is 8
The result of 3 * 88 is 264
The result of 45 * 68 is 3060
The result of 81 - 0 is 81
The result of 77 + 40 is 117
The result of 8 * 84 is 672
The result of 73 - 22 is 51
The result of 85 - 86 is -1
The result of 28 * 58 is 1624
Transcribed Image Text:b) You are given a file "input1b.txt". The first line of the input file will contain an integer T, representing the number of test cases. The next T lines will contain a single arithmetic expression. Each arithmetic expression will start with the prefix "calculate". It is guaranteed that the expression will have exactly two operands and one operator. Calculate the result based on the operation (operator) on the operands and for each line of expression, write the result with "The result of $a $operator $b is $result" where $a and $b are the values of the first and second operator respectively, and $operator is the operator and $result is the result of the operation. All the results must be compiled in a single file, "output1b.txt." Sample Input File 15 calculate 67 +41 calculate 85/5 calculate 13 - 56 calculate 99 - 95 calculate 3/10 calculate 12* 19 calculate 14 - 6 calculate 3* 88 calculate 45 * 68 calculate 81 - 0 calculate 77 + 40 calculate 8 * 84 calculate 73-22 calculate 85-86 calculate 28 * 58 Sample Output File The result of 67 +41 is 108 The result of 85/5 is 17.0 The result of 13 - 56 is -43 The result of 99 - 95 is 4 The result of 3/10 is 0.3 The result of 12 * 19 is 228 The result of 14 - 6 is 8 The result of 3 * 88 is 264 The result of 45 * 68 is 3060 The result of 81 - 0 is 81 The result of 77 + 40 is 117 The result of 8 * 84 is 672 The result of 73 - 22 is 51 The result of 85 - 86 is -1 The result of 28 * 58 is 1624
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education