Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Programming # include <stdio.h> Assignment Twelve - CIS 170 C Programming Grou

ID: 3595227 • Letter: C

Question

C Programming

# include <stdio.h>

Assignment Twelve - CIS 170 C Programming Group Assignment program that calculates and displays the total travel expenses ofa The total number of days spent on the trip home on the last day of the trip n on a trip. The program should ask for and do the following: 2. e of departure on the first day of the trip, and the time of arrival back 3. The amount of any round-trip airfare (company pays for this in total). 4. Th 3: Niles driven, if a private vehicle was used. Calculate the vehicle expense as $.53 6. Parking fees (the company allows up to $6 per day. Anything in excess of this 7. Taxi fees, if a taxi was use anytime during the trip (the company allows up to e amount of any car rentals (company pays for this in total). per mile driven must be paid by the employee). $10 per day, for each day a taxi was used. Anything in excess of this must be paid by the employee) 8. Conference or seminar registration fees (company pays for this in total) 9. Hotel expenses (the company allows up to $90 per night for lodging. Anything in excess of this must be paid by the employee) 10.The amount of each meal eaten. On the first day of the trip, breakfast is allowed as an expense if the time of departure is before 7am. Lunch is allowed if the time of departure is before 12 noon. Dinner is allowed if the time of departure is before 6pm. On the last day of the trip, breakfast is allowed if the time of arrival is after 8am. Lunch is allowed if the time of arrival is after 1pm. Dinner is allowed if the time of arrival is after 7pm. The program should only ask for the amounts of allowable meals. (The company allows up to $9.00 for breakfast, $12 for lunch, and $16 for dinner. Anything in excess of this must be paid by the employee) The program should calculate and display the total expenses incurred by the businessperson, the total allowable expenses for the trip, the excess that must be reimbursed by the businessp if the expenses were under the total allowed. erson, if any, and the amount saved by the businessperson You must also check for input validation. Do not accept negative numbers for any dollar amount or for miles driven in a private vehicle. Do not accept numbers less than 1 for the number of days. Only accept valid times for the time of departure and the time of arrival. The main) function will prompt the user for the number of days for the business trip

Explanation / Answer

#include<stdio.h>
#include<conio.h>

int timeofdep,timeofarr,noofday;

float carFare(){
int choice,mile;
float total = 0;
start:
printf("Pick the integer from given choice .... ");
printf(" 1. Renting a car...");
printf(" 2. Taking a Taxi ");
printf(" 3. Driving Your Own car enter your choice ...   ");

scanf("%d",&choice);
switch(choice){
  case 1:
   car:
   printf(" Enter The Amount of your car rent in dollar ... ");
   scanf("%f",&total);
   if(total < 0){
    printf(" You Entered wrong value");
    goto car;
    }
   return total;
  case 2:
   total = noofday * 10;
   return total;
  case 3:
  mil:
  printf(" Please Enter the Miles You drive in your Trip ... ");
  scanf("%d",&mile);
  if(mile < 0){
  printf(" You Entered wrong value");
  goto mil;
   }
  total = 0.53*mile;
  return total;
  default:
      printf(" you entered the wrong choice please try again...");
      goto start;
}
}

float hotelFare(){
int day = 0;
hotel:
printf(" Enter The no of night you spent in hotel .. ");
scanf("%d",&day);
if(day < 0){
  printf(" You Entered wrong value");
  goto hotel;
}
return (90.0 * day);
}

float airFare(){
float total = 0;
air:
printf(" Enter the amount of any air fare round trip ...");
scanf("%f",&total);
if(total < 0){
  printf(" You Entered wrong value");
  goto air;
}
return total;
}

float milFare(){
float total = 0;
if(timeofdep < 7 ){
    total = total + 9;
}
if(timeofdep < 12){
  total = total +12;
}
if(timeofdep < 18){
  total = total + 16;
}
if(noofday > 2)
total = total + (noofday - 2)*37;

if(timeofarr > 8){
  total = total + 9;
}
if(timeofarr > 13){
  total = total +12;
}
if(timeofarr > 19){
  total = total + 16;
}
return total;

}

float regFare(){
float total = 0;
reg:
printf(" Enter the registration fee of the conference or seminar ..");
scanf("%f",&total);
if(total < 0){
  printf(" You Entered wrong value");
  goto reg;
}
return total;
}

float finalCalc(){
return airFare()+carFare()+hotelFare()+milFare()+regFare();
}

void displayFare(float cost){
printf(" Total Company Payable Amount to the employer is %f $ ",cost);
printf(" Thank You for calculating the fare have good day");
}

int main(){
printf("    Welcome To Expenses Calculator ..... ");
timed:
printf(" Enter The departure time of 24 hour clock   ");
scanf("%d",&timeofdep);
if(timeofdep < 1 && timeofdep > 24){
  printf(" You Entered wrong value");
  goto timed;
}
timeA:
printf(" Enter The arrival time of 24 hour clock");
scanf("%d",&timeofarr);
if(timeofarr < 1 && timeofarr > 24){
  printf(" You Entered wrong value");
  goto timeA;
}
NoofDay:
printf(" Enter The no of days of the trip.. ");
scanf("%d",&noofday);
if(noofday < 0){
  printf(" You Entered wrong value");
  goto NoofDay;
}
float totalCost = finalCalc();
displayFare(totalCost);

return 0;
}