This is my assignment and I was able to write the below code so far. But I'm getting theerrors. Please Help !
This is the question:
Write a program that first prompts users for their full names (store each first, middle, and last -
in three separate character arrays), hours worked, hourly rates, and tax rates, and then displays
taxes and net pay, using the appropriate dollars-and-cents print codes.
Sample output:
First Middle Last Hours-Worked Hourly-rate Tax-rate Taxes Net-pay
------ ------------- ------------ ----------- -------- ----- -------- ---------
Jim V. Wrenn 40 $10.7 20% $85.6 $342.4
Code:
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<conio.h>
void main()
{
int i,j;
printf(" Please enter the number of people \n\n");
scanf("%d",&i);
char fname[i][10],mname[i][10],lname[i][10]; // Strings for first name, middle name, last name.
float hours[i], hoursrate[i], taxes[i], netpay[i], taxrate[i]; //arrays for hours worked,$/hr,taxes...
for(j=0;j<i;j++)
{
printf("Please enter First Name, Middle Name, Last Name, Number of Hours worked, Hourly pay, Tax Rate");
scanf(" \n\n\n %s %s %s %f %f %f ", fname[j], mname[j], lname[j], &hours[j], &hoursrate[j], &taxrate[j]); //Taking full name and work details
}
printf(" %8s %8s %8s %8s %8s %8s %8s %8s \n","fname","mname","lname","hours","$/hr","taxrate","taxes","pay");
for(j=0;j<i;j++)
{
taxes[j]=(hours[j]*hoursrate[j])*(taxrate[j]/100); //calculating taxes for each person
netpay[j]=(hours[j]*hoursrate[j])-taxes[j]; //calculating net pay
printf(" %8s %8s %8s %8.2f %8.2f %8.2d %8.2f %8.2f \n",fname[j],mname[j],lname[j],hours[j],hoursrate[j],taxrate[j],taxes[j],netpay[j]);
}
}