31 lines
914 B
C
31 lines
914 B
C
/*
|
|
Nicholas Pease
|
|
HW5B - User Input Request
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
// I set this equal to 2023, as this is the current year. However it seems in the example code, it is still set to 2022
|
|
#define CURRENT_YEAR 2023
|
|
|
|
int main() {
|
|
// start input
|
|
// char[20] name - string for name input
|
|
// int birthyear - applicant birth year
|
|
// double salary - requested monthly salary
|
|
char name[20];
|
|
int birthyear;
|
|
double salary;
|
|
printf("New applicant's name: ");
|
|
fgets(name,20,stdin);
|
|
// Strip newline character
|
|
for (int i=0; i<20;i++) if (name[i] == '\n') name[i] = '\0';
|
|
printf("Enter applicant's birth year: ");
|
|
scanf(" %d",&birthyear);
|
|
printf("Enter monthly salary (USD): ");
|
|
scanf(" %lf",&salary);
|
|
// end input section
|
|
printf("%s is a %d years old applicant and requests a monthly salary of $%.2lf.\n",name,CURRENT_YEAR - birthyear,salary);
|
|
return 0;
|
|
} |