Question: Functional Programming Use: C++ Functional programming is all about composition. To compose functions, they need to return a type; you cannot compose functions that don't

Functional Programming

Use: C++ Functional programming is all about composition. To compose functions, they need to return a type; you cannot compose functions that don't return anything (i.e. void).

Q: Write a program that reads table with given columns from input stream. Columns are name(note: firstname and lastname are in one column, so use getline maybe), amount, debt. Then filter the table (condition: debt is equal to 0). After that increase debt by 42% then print results.

Input:

5 Solomon Anderson 411889 36881 Jill Mitten 121877 0 Katie Nicholson 783887 591951 Ben Hen 445511 0 Adam Millington 818507 276592

Output:

Solomon Anderson 411889 52371.02 Katie Nicholson 783887 840570.42 Adam Millington 818507 392760.64

-----------------------------------------------------------------------------------

Think of what you need:

- you need to know how many lines of input you have

- convert N lines of input into some form of list with N elements

- filter a list of N such elements and reduce it to a list with M elements

- modify that list (commonly referred to as "map" the list) - you need to print the list.

So you should get print( map( filter( readLines( getInputSize() ) ) ) ) in the main section.

**PLEASE READ CAREFULLY BEFORE ANSWERING**

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!