Answered! The program uses loop to read inputs (from standard in), one input per line, about the user information in the form…

Write a C program. Finish incomplete code

Reads user info from standar input, outputs modified versions of the records.

The program uses loop to read inputs (from standard in), one input per line, about the user information in the form of name age wage, where name is a word (with no space), age s an integer literal, and wage is a floating point literal with up to 2 decimal number. See sample input below uses scanf S s s name, age, wage) to read in three input strings where name, age and wage are of type charl201 The program should after reading each line of inputs, creates a char [40] string resu for the modified version of the input. In the modified version ofinput, the first letter of name is capitalized age becomes age 10, and wage has 100% increases with 3 digit after decimal point, followed by the floor and ceiling of the increase wage. The values are separated by dashes as shown below. How to create resu?) then duplicate/copy resu to resu2 using a library function declared in string.h then duplicate/copy resu to resu3 using a library function declared in <stdio.h then output the resulting strings resu resu2 and resu3 continue reading input, until a name xxx is entered (followed by any two words) 4.3 Sample inputs/outputs red 11 a out Enter ame age and wage (xxx to guit Ying 22 33.3 Yin-32-66. 600 66-67 Ying-32-66.600-66-67 Ying-32-66.600-66-67 Enter name age and wage (xxx to quit john 60 1. O John-70-2.000-2-2 John-70-2.000-2-2 John-7 0-2 -2 2.000-2 Enter name, age and wage (XXX to quit lisa 30 1.34 Lisa-4 0-2 68 0-2-3 Lisa -4 0-2 68 0-2-3 Lisa-4 0-2 68 0-2-3

INCOMPLETE CODE

#include

#define SIZE 10
#define SIZE2 40

int main(int argc, char *argv[])
{

char name[SIZE], wage[SIZE], age[SIZE];
char resu[SIZE2], resu2[SIZE2], resu3[SIZE2];

printf(“Enter name, age and wage (xxx to quit): “);
scanf(“%s %s %s”, name, age, wage);
while ()
{

/* use scanf to read again */

}
return 0;
}

The program uses loop to read inputs (from standard in), one input per line, about the user information in the form of name age wage, where name is a word (with no space), age s an integer literal, and wage is a floating point literal with up to 2 decimal number. See sample input below uses scanf S s s” name, age, wage) to read in three input ‘strings where name, age and wage are of type charl201 The program should after reading each line of inputs, creates a char [40] string resu for the modified version of the input. In the modified version ofinput, the first letter of name is capitalized age becomes age 10, and wage has 100% increases with 3 digit after decimal point, followed by the floor and ceiling of the increase wage. The values are separated by dashes as shown below. How to create resu?) then duplicate/copy resu to resu2 using a library function declared in string.h then duplicate/copy resu to resu3 using a library function declared in

Expert Answer

 Code:

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>

#define SIZE 10
#define SIZE2 40

int main(int argc, char *argv[])
{
char name[SIZE], wage[SIZE], age[SIZE];
char resu[SIZE2], resu2[SIZE2], resu3[SIZE2];
double wage_d;
int age_i;

printf(“Enter name, age and wage(XXX to quit): “);
scanf(“%s %s %s”, name, age, wage);
while(1){
/* program will quit when user enters XXX as input for ‘name’ variable */
if(strcmp(name, “XXX”) == 0)
break;

/* converting the first character of name to upper case */
name[0]=toupper(name[0]);
/* we cannot do arithmetic on character array. Hence converting to integer and adding 10 to age */
age_i = atoi(age) + 10;
/* we cannot do arithmetic on character array. Hence converting to float value and increasing the wage to 100% */
wage_d = atof(wage) * 2;

/* printing the formatted string in required format in resu character array */
sprintf(resu, “%s-%d-%.3f-%.0f-%.0f”, name, age_i, wage_d, floor(wage_d), ceil(wage_d));

/* copying character array resu to resu2 using strcpy library function from string.h */
strcpy(resu2, resu);

/* copying character array resu to res3 using sprintf library function from stdio.h */
sprintf(resu3, “%s”, resu);

printf(“n%s %s %sn”, resu, resu2, resu3);
break;
}

return 0;
}

Execution and output:
Unix Terminal> ./a.out
Enter name, age and wage(XXX to quit): ying 22 33.33

Ying-32-66.660-66-67 Ying-32-66.660-66-67 Ying-32-66.660-66-67Unix Terminal> vi sample.c
Unix Terminal> cc sample.c
Unix Terminal> ./a.out
Enter name, age and wage(XXX to quit): ying 22 33.33

Ying-32-66.660-66-67 Ying-32-66.660-66-67 Ying-32-66.660-66-67
Unix Terminal> ./a.out
Enter name, age and wage(XXX to quit): john 60 1.0

John-70-2.000-2-2 John-70-2.000-2-2 John-70-2.000-2-2
Unix Terminal> ./a.out
Enter name, age and wage(XXX to quit): lisa 30 1.34

Lisa-40-2.680-2-3 Lisa-40-2.680-2-3 Lisa-40-2.680-2-3
Unix Terminal> ./a.out
Enter name, age and wage(XXX to quit): XXX XXX XXX
Unix Terminal>

Still stressed from student homework?
Get quality assistance from academic writers!