Question

In: Computer Science

In C program #include<stdio.h> You found an exciting summer job for five weeks. Suppose that the...

In C program

#include<stdio.h>

You found an exciting summer job for five weeks.

Suppose that the total tax you pay on your summer job income is 14%.

After paying the taxes, you spend:

  • You spend 10% of your net income to buy new clothes and other accessories for the next school year
  • You 1% to buy school supplies
  • AFTER buying clothes and school supplies, you save 25% of the remaining money
  • For each dollar you save, your parents add $0.50 additional savings

Write a program that prompts the user to enter the pay rate for an hour and
the number of hours you worked each week.

For example, if you earned $10.00/hour and worked 10 hours per week....
the program should output the following:


|----------|--------------------------------------------------|
| $ 10.00 | Hourly Rate |
| 50.00 | Total Hours Worked |
|----------|--------------------------------------------------|
| $ 500.00 | Total Income before tax |
| $ 430.00 | Net Income |
| $ 43.00 | Money spent on clothes and other accessories |
| $ 4.30 | Money spent on school supplies |
| $ 95.67 | Money spent on savings |
| $ 47.84 | Money spent by parents on additional savings |
|----------|--------------------------------------------------|


REQUIREMENT: Use printf format descriptors to format the rows of the table.

Solutions

Expert Solution

A C program for above furnished information is as below :

#include <stdio.h>

int main()
{
float hr,hw,thw,tibt,ni,mc,ms,msa,ab,mas;
printf("Please enter rate per hour(without currency symbol) :");
scanf("%f",&hr);
printf("\n");
printf("Please enter worked hours per week :");
scanf("%f",&hw);
printf("\n");
thw=hw*5;
printf("|--------|---------------------------------------------|\n");
printf("|$%.2f| Hourly Rates|\n",hr);
printf("|%.2f|Total Hours Worked|\n",thw);
printf("|--------|---------------------------------------------|\n");
tibt=(((hr*thw)*100)/100);
printf("|$%.2f|Total Income before tax|\n",tibt);
ni=(tibt - ((tibt*14)/100));
printf("|$%.2f|Net Income|\n",ni);
mc=(ni/10);
printf("|$%.2f|Money spent on clothes and other accessories|\n",mc);
ms=(mc/10);
printf("|$%.2f|Money spent on school supplies|\n",ms);
msa=((((ni-mc-ms)*25)/100));
ab=floor(msa*100)/100;
printf("|$%.2f|Money spent on savings|\n",ab);
mas=(msa/2);
printf("|$%.2f|Money spent by parents on additional savings|\n",mas);
printf("|--------|---------------------------------------------|\n");
return 0;
}

Note : - It used float data type and while entering hourly rate , please ignore $ symbol for hourly rate.


Related Solutions

Include<stdio.h> In C program Write a program that prompts the user to enter an integer value....
Include<stdio.h> In C program Write a program that prompts the user to enter an integer value. The program should then output a message saying whether the number is positive, negative, or zero.
*Answer in C program* #include <stdio.h> int main() {      FILE *fp1;      char c;     ...
*Answer in C program* #include <stdio.h> int main() {      FILE *fp1;      char c;      fp1= fopen ("C:\\myfiles\\newfile.txt", "r");      while(1)      {         c = fgetc(fp1);         if(c==EOF)             break;         else             printf("%c", c);      }      fclose(fp1);      return 0; } In the program above which statement is functioning for opening a file Write the syntax for opening a file What mode that being used in the program. Give the example from the program Referring to...
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include...
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include <string.h> #include <ctype.h> int main(int argb, char *argv[]){ char ch; int upper=1; if(argb>1){ if(strcmp(argv[1],"-s")==0){ upper=1; } else if(strcmp(argv[1],"-w")==0){ upper=0; } } while((ch=(char)getchar())!=EOF){ if(upper){ printf("%c",toupper(ch)); } else{ printf("%c",tolower(ch)); } } return 0; } ======================================================== #include <stdio.h> #include <stdlib.h> int calcRange(int array[],int size){ int max=array[1]; int min=array[0]; int a=0; for(a=1;a<size;a++){ if(array[a]>max){ max=array[a]; } } for(a=1;a<size;a++){ if(array[a]<min){ min=array[a]; } } printf("%d-%d=%d\n",max,min,max-min); } int main(int arga, char **argv){...
construct c program flow chart #include <stdio.h> #include <math.h> #include <string.h> #define num 6 #define b...
construct c program flow chart #include <stdio.h> #include <math.h> #include <string.h> #define num 6 #define b 6 #define t 6 double bmical(double w, double h){ double o; double bmi; o = pow(h,2); bmi = w/o; return bmi; } double maxheartrate(int num1, int age){ double mhr; mhr = num1 - age; return mhr; } double heartratereserve(double mhr, double rhr){ double hrr; hrr = mhr - rhr; return hrr; } double minrange(int hrr, int rhr){ double mirt; mirt = (hrr * 0.7)...
*Answer in C program* Given a program as shown below: #include <stdio.h> void function1(void); void function2...
*Answer in C program* Given a program as shown below: #include <stdio.h> void function1(void); void function2 (int, double x); void main (void) { int m; double y; m=15; y=308.24; printf ("The value of m in main is m=%d\n\n",m); function1(); function2(m,y); printf ("The value of m is main still m = %d\n",m); } void function1(void) { printf("function1 is a void function that does not receive\n\\r values from main.\n\n"); } void function2(int n, double x) { int k,m; double z; k=2*n+2; m=5*n+37;...
Can you translate this C code into MIPS assembly? #include <stdio.h> #include <math.h> #include <stdlib.h> double...
Can you translate this C code into MIPS assembly? #include <stdio.h> #include <math.h> #include <stdlib.h> double fact (double); void main () { int angle_in_D; double term, angle_in_R; float sine = 0; unsigned int i = 1; double sign = 1; int n = 1000; printf ("Please enter an angle (Unit: Degree): "); scanf ("%d", &angle_in_D); angle_in_R = angle_in_D * M_PI / 180.0; do { term = pow(-1,(i-1)) * pow (angle_in_R, (2*i - 1)) / fact (2*i - 1); sine =...
What is the output of the following C program? #include<stdio.h> int fac (int x); void main(...
What is the output of the following C program? #include<stdio.h> int fac (int x); void main( ) {                         for (int i=1; i<=2; i++)                                     printf("%d", fac(i)); } int fac(int x) {                         x = (x>1) ? x + fac(x-1) : 100);                         return x; }
(12) Explain what will be output of the following program? #include <stdio.h> #include <stdlib.h> #include <pthread.h>...
(12) Explain what will be output of the following program? #include <stdio.h> #include <stdlib.h> #include <pthread.h> #define NUM_THREADS 3 /* create thread argument struct for thr_func() */ typedef struct _thread_data_t {   int tid;   double stuff; } thread_data_t; /* thread function */ void *thr_func(void *arg) {   thread_data_t *data = (thread_data_t *)arg;   printf("hello from thr_func, thread id: %d\n", data->tid);   pthread_exit(NULL); } int main(int argc, char **argv) {   pthread_t thr[NUM_THREADS];   int i, rc;   thread_data_t thr_data[NUM_THREADS];   /* create threads */   for (i = 0;...
Write a C++ program to choose one of the following five options for your summer vacation...
Write a C++ program to choose one of the following five options for your summer vacation Hawaii Bahamas Cancun Las Vegas Europe Your program should select one of the above option. Once the option is selected then your program should select one of the following airlines: US Air Delta Southwest Continental American Airline Once the airline is selected then read number of passengers airfare for round trip. Calculate the total charge. make your own charges
3. Write a C++ program to choose one of the following five options for your summer...
3. Write a C++ program to choose one of the following five options for your summer vacation 1. Hawaii 2. Bahamas 3. Cancun 4. Las Vegas 5. Europe Your program should select one of the above option. Once the option is selected then your program should select one of the following airlines: 1. US Air 2. Delta 3. Southwest 4. Continental 5. American Airline Once the airline is selected then read number of passengers airfare for round trip. Calculate the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT