Question

In: Computer Science

Using C language: (Note: If a family of 4, apply family of 3 cost plus the...

Using C language: (Note: If a family of 4, apply family of 3 cost plus the cost of 1 participant. K800 is the fixed cost for a family of 3.)

A bus company organizes a tour. The tour is open for 4 days and participants can register for the number of days they would like to participate in the tour. Each participant would pay K 300 for the tour per day, a family of 3 would pay K 800 per day, and a family of 5 would pay K 1000 per day Write a program that calculates the cost of participating in the tour The program reads the number of participants input by the user, and the number of days of participation Based on these variables and the prices outlined for the tour, the program should then calculate the total cost of participating in the tour If a participant(s) registers for more than 2 days of the tour, the first 2 days will be at full price while the days after will be at half price Include the program algorithm in your design.

Solutions

Expert Solution

Below is the code which return the cost of participants. It is running perfect on CodeBlocks compiler

The program first check whether the no of participants are 1,2,3,4,5 or more than 5 and the corresponding cost is calculated.

After this, It is multiply with the no of days.

for example . no of participants = 9, no of days =3;

cost= 1000+800+300=2100

final cost = 2100*2 + 2100/2= 5250

------------------------------------------------------------------------------------------------

#include<stdio.h>
void main()
{
int number_of_days,number_of_participants,no; // no is divisor used to calculate the days which are more than 5
int cost=0;
scanf("%d%d",&number_of_participants,&number_of_days);
if(number_of_participants==1 || number_of_participants==2)
cost+=300*number_of_participants;
else if(number_of_participants==5)
cost+=1000;

else if(number_of_participants==3)
cost+=800;
else if(number_of_participants==4)
cost+=800+300;
else if(number_of_participants>5)
{
no=number_of_participants/5;
number_of_participants=number_of_participants%5;
cost=cost+1000*no;

if(number_of_participants==1 || number_of_participants==2)
{
cost+=300*number_of_participants;

}

else if(number_of_participants==3)
cost+=800;
else if(number_of_participants==4)
cost+=800+300;

}

if(number_of_days==2)
{
cost=cost*2;
}
else if(number_of_days>2)
cost=cost*2+(cost*(number_of_days-2))/2;
printf("cost of partipants : %d",cost);

}

----------------------------------------------------------------------------------------------------------------


Related Solutions

using c plus plus: THE PROGRAMS SHOULD 3 DIFFERENT PARTS AS MAIN, STUDENTTYPE.H AND STUDENTTYPELMP.CPP. I...
using c plus plus: THE PROGRAMS SHOULD 3 DIFFERENT PARTS AS MAIN, STUDENTTYPE.H AND STUDENTTYPELMP.CPP. I ALWAYS GRADE MY ANSWERS. THANKS. Chapter 9 defined the struct studentType to implement the basic properties of a student. Define the class studentType with the same components as the struct studentType, and add member functions to manipulate the data members. (Note that the data members of the class studentType must be private.) Write a program to illustrate how to use the class studentType. Struct...
Using C Language Write a program segment that computes 1 + 2 + 3 + ......
Using C Language Write a program segment that computes 1 + 2 + 3 + ... + ( n - 1) + n , where n is a data value. Follow the loop body with an if statement that compares this value to (n * (n + 1)) / 2 and displays a message that indicates whether the values are the same or different. Please give me code to just copy and paste
Note: I need a code and other requirement Note: programming language is c++ If you need...
Note: I need a code and other requirement Note: programming language is c++ If you need more information, please clarify what information you want. consider solving the equation sin(x) - e^(-x) = 0 write a computer program to solve the given equation using: 1- bisection method 2- fixed-point method 3- newton's intervals: {0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{8,9},{9,10} choose accuracy E = 10^(-5) Make sure you document your program Requirement : 1- Mathematical justification 2- algorithem description 3- code (program) with documentation 4-output: roots ,...
Write a program, using any language you want, to sort the following using QuickSort: {3, 4,...
Write a program, using any language you want, to sort the following using QuickSort: {3, 4, 5,1, 2, 6, 7, 8}
Language: C++ 3 Campus Travel Game This lab will practice using loops. We will construct a...
Language: C++ 3 Campus Travel Game This lab will practice using loops. We will construct a short computer game. Please look at the Test Cases for exact wording. For your game, the player’s goal is to reach campus exactly. The player starts 14 miles away and has up to 4 turns to reach campus. At each turn the play can ride either use a Bus, a Subway, or a Jetpack: Riding a Bus moves the player forward 2 miles each...
on C++ language please and if you can also put note on it to better undertand...
on C++ language please and if you can also put note on it to better undertand it. Write a program that reads data from a data file, the value of which is provided at the end of the problem. Your program is to incorporate the following requirements: Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many numbers are in the file. Save the output of...
Complete parts (a) through (c) using the following data. Row 1: 1 3 3 4 4...
Complete parts (a) through (c) using the following data. Row 1: 1 3 3 4 4 4 5 6 6 7 Row 2: 90 82 76 76 90 72 80 90 55 70 A.) Find the equation of the regression line for the given data, letting Row 1 represent the x-values and Row 2 the y-values. Sketch a scatter plot of the data and draw the regression line. Input the values of the slope and intercept for the regression line...
TO BE DONE IN C LANGUAGE BEFORE READING THE QUESTION PLEASE NOTE THAT YOUR FUNCTION SHOULD...
TO BE DONE IN C LANGUAGE BEFORE READING THE QUESTION PLEASE NOTE THAT YOUR FUNCTION SHOULD EXACTLY PRODUCE THE GIVEN OUTPUT AND THE TIME COMPLEXITY SHOULD BE O(N^2) YOU NEED TO KNOW ABOUT COCKTAIL SHAKER SORT ALGORITHM: Cocktail-shaker sort is a modification of Bubble sort. Cocktail-shaker sort traverses the data structure in one direction, pushing the largest element ahead towards one end of the data structure, and then in the opposite direction, pushing the smallest element towards the other end,...
(IN C LANGUAGE) The cost to become a member of a fitness center is as follows:...
(IN C LANGUAGE) The cost to become a member of a fitness center is as follows: (a) the senior citizens discount is 30% (b) if the membership is bought and paid for 12 or more months, the discount is 15% (c) if more than five personal training sessions are bought and paid for, the discount on each session is 20% Write a that determines the cost of a new membership. Your program must contain: a function that displays the general...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library...
Programming Language Required: C Write a multithreaded program in C (not c++) using the pthread library and dynamic memory(malloc) that multiplies two matrices together. The numbers in the matrices must be read in from a text file. The program should also check if the two matrices are capable of being multiplied together. The amount of threads used has to be dynamic. The user should be able to choose how many threads they wish to use using the command line. Finally,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT