Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Specification Write an ANSI-Cprogram that reads user information from the standard inputs, and outputs both the original and the modified version of the records. Implementation

image text in transcribed
image text in transcribed
image text in transcribed
Specification Write an ANSI-Cprogram that reads user information from the standard inputs, and outputs both the original and the modified version of the records. Implementation A file lab4table1.c is for you to get started. The program should: use a table-like 2-D array (i.e., an array of 'strings") to record the inputs. use loop and scanf("%s %s %s") to read inputs (from standard in), one input per line, about the user information in the form of name age rate, where name is a word (with no space), age is an integer literal, and rate is a floating point literal. See sample input below. store each input string into the current available 'row of the 2D array, starting from row 0. create a modified string of the input, and store it in the next row of the 2D array. In the modified version of input, all letters in name are capitalized, age becomes age +10, and rate has 50% increases and is formatted with 2 digits after decimal point. continue reading input, until a name xxx is entered, followed by any age and rate values. after reading all the inputs, output the 2-D array row by row, displaying each original input followed by the modified version of the input. display the current date and time and program name before generating the output, using predefined pre-processor macros such as _FILE__ _TIME_ (implemented for you). Note that as the partial implementation shows, each input line is read in as three 'strings' using scanf("%s %s %s", ..). In the next question, you will practice reading in the whole line as a string, as in lab4fgets and then tokenize the string). Each approach has its pros and cons. Note that you will lose all marks if, instead of a 2D-array, you use 3 parallel 1-D arrays -- one of names, one of ages, one for wages -- to store and display information. Sample Inputs/Outputs: red 307 8 a. out Enter name, age and rate: john 60 1.0 Enter name, age and rate: eric 30 1.3 Enter name, age and rate: lisa 22 2.2 Enter name, age and rate: Judy 40 3.2254 Enter name, age and rate: xxx 2 Records generated in lab4table1.c on Feb 10 2021 13:32:48 row[0]: John 60 1.0 row[1] : JOHN 70 1.50 row [2] : eric 30 1.3 row[3): ERIC 40 1.95 row [4] : lisa 22 2.2 row [5): LISA 32 3.30 row[6): Judy 40 3.2254 row [7]: JUDY 50 4.84 red 308 % Sample Inputs/Outputs: (download file inputs.txt) red 309 $ a.out #include #include #include #define ROWS 20 #define COLUMNS 30 int main(int arge, char *argv[]) { char inputs_table [ROWS] [COLUMNS) ; char name[10]; char ages[10]; char rates[10]; printf("Enter name, age and rate: "); scanf("%s %s $s", name, ages, rates); while (...) { /* read again using scanf( $s $s $s) */ } printf(" Records generated in $s on $s $s ", FILE DATE_ TIME__); /* now display the input_table row by row */ return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions