Task:
We want to make a simple calculator that can add and subtract integers and will ac...
Computers and Technology, 20.02.2020 08:53 elizabethhodge76
Task:
We want to make a simple calculator that can add and subtract integers and will accept arbitrarily long mathematical formulas composed of symbols +, -, and non-negative integer numbers.
Imagine you have a file formula. txt with the summation formula such as:
100 + 50 - 25 + 0 + 123 - 1
If you redirect the file into your program, it should compute and print the
$ ./calc < formula. txt
247
Specifically, write a program calc. cpp that reads from the cin a sequence of one or more non-negative integers written to be added or subtracted. Space characters can be anywhere in the input. After the input ends (end-of-file is reached), the program should compute and print the result of the input summation.
Possible input that has spaces and characters:
1 + 1 + 1 + 1 +
1 + 1 + 1 + 1 +
1 + 1 + 1 + 1 +
1 + 1 + 1 + 1
Possible output: 16
You can use >> operator to read the numbers and the +/- characters, because >> will be skipping all spaces between the input terms.
WHat would the program be here? How would i successfully read in the file and get the right output?
Thanks
Answers: 3
Computers and Technology, 23.06.2019 09:30
Name the range function that would generate the following list of integers values: 0,1,2,3,4,5.
Answers: 1
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
Computers and Technology, 24.06.2019 09:40
Healthy study habits are best described as
Answers: 1
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
Mathematics, 14.07.2020 01:01
Mathematics, 14.07.2020 01:01
Health, 14.07.2020 01:01
Mathematics, 14.07.2020 01:01
Mathematics, 14.07.2020 01:01
English, 14.07.2020 01:01
Chemistry, 14.07.2020 01:01
Biology, 14.07.2020 01:01
Mathematics, 14.07.2020 01:01