Question

In: Computer Science

In C language, Calculate the price of parking: First 60 minutes is Free; 61-80 minites is...

In C language, Calculate the price of parking:
First 60 minutes is Free;
61-80 minites is $4
Each additionat 20 minutes is $2
Maximum rate per day is $18 (24 hrs), so once it passes the 4 hrs to 24hrs parked will be $18
Note: If the input is invalid, print message “invalid input” and exit the program.

Example:

Hrs Parked: 8
Minutes Parked: 20
Price: $18
———————// If its over 24hrs add the previous days plus the new rate
Hrs Parked: 26
Minutes Parked: 28
Price: $34
———————
Hrs Parked: 95
Minutes Parked: 60
Price: $72

Solutions

Expert Solution

#include<stdio.h>

int main() {
int hpark,mpark,totalmin,price=0;
printf("Hours Parked: ");
scanf("%d",&hpark);
printf("\nMinutes Parked: ");
scanf("%d",&mpark);
totalmin=(hpark*60)+(mpark);
do{
if(totalmin<=60)
{
price=price+0;
}
else if(totalmin>60 && totalmin<=240)
{
price=price+((totalmin/20)*2);
  
}
else if(totalmin>=240)
{
price=price+18;
}
hpark=hpark-24;
totalmin=(hpark*60)+(mpark);
}while(hpark>0);
  
printf("\nPrice is:%d",price);
}


Related Solutions

Free parking spots in a crowded tourist town are ______ goods. A. public b. club c....
Free parking spots in a crowded tourist town are ______ goods. A. public b. club c. private d. common
language c++ finish the code and hurry in an exam with less then 30 minutes #include...
language c++ finish the code and hurry in an exam with less then 30 minutes #include <iostream> #include <vector> using namespace std; int find(vector<int> & v, int value); int main(){ vector<int> myVec = {2,30,10,50,100,32,19,43, 201, 311, 99,77,45,15,95, 105, 32, 15}; //complete code here cout << "First Element is: " << endl; cout << "Last Element is: " << endl; cout << "The number of elements is: " << endl;    //Complete the missing code cout << "Find 201 : result...
Using the C language: In the old days, data was stored on punched cards of 80...
Using the C language: In the old days, data was stored on punched cards of 80 or 96 columns. Presume your job is to update a database to include the newly found data in the file punchcard.txt into a currently used data base. In order to do that, you must read in the data in columnar format and convert it to comma separated fields so it can be imported. Using buffered I/O functions (e.g. fopen, fclose, fprintf, fscanf, fread or...
C language you are to write a a program that will first read in the heights...
C language you are to write a a program that will first read in the heights and weights of a series of people from a file named values.dat. Create this file using your editor so that each line contains a height and corresponding weight. For instance, it might look likea: 69.0 125.0 44.0 100.0 60.0 155.0 49.0 190.0 65.0 115.0 50.0 80.0 30.0 129.0 72.0 99.0 68.0 122.0 50.0 105.0 and so on. The formula for the standard deviation of...
You are using ONLY Programming Language C for this: In this program you will calculate the...
You are using ONLY Programming Language C for this: In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out: 1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array. 2. Use the function to scan the grades of the array. To say another...
in assembly language x86 Masm, Write a program that calculate the first seven values of the...
in assembly language x86 Masm, Write a program that calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(0) = 0, Fib(1) = 1, Fib(2) = Fib(0)+ Fib(1), Fib(n) = Fib(n-1) + Fib(n-2). You NEED to calculate each value in the series "using registers and the ADD operation" You can also use variables, Have your program print out "The first seven numbers is" Use WriteInt for the printing, Place each value in the EAX...
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display...
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display the area and perimeter of a rectangle with width = 4 and height = 8.
Write this program in a C++ language Calculate the ideal age of a spouse. Enter either...
Write this program in a C++ language Calculate the ideal age of a spouse. Enter either m or f from the keyboard in lower case. You may use string data for the gender. Convert the gender to upper case Enter an age from the keyboard, probably an integer You will need prompts telling the user what to enter. Use an IF statement to determine if the person is a male or female. You do one calculation if the person is...
If possible, calculate total profits given a price of $80, an average total cost of $30,...
If possible, calculate total profits given a price of $80, an average total cost of $30, and an output of 5. If price is above average total cost, is the firm making a profit or loss and should it operate or shut down? None of the above. Profit and it should operate. Loss and it should shut down to minimize losses. Loss and it should operate to minimize losses. Suppose that a firm is making a profit of $50 million...
C++ language Write a program that accepts as input the base price and the finished area...
C++ language Write a program that accepts as input the base price and the finished area in square feet of the three models. The program outputs the model(s) with the least price per square foot in the following format: If the colonial model is the least price, output: The price per square foot of the colonial model is the least. If the split-entry model is the least price, output: The price per square foot of the split-entry model is the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT