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...
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...
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...
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate...
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate the average score and scores below 60. Then display the average score and number of scores below 60
Programming Language C++ Task 1: Write a program to calculate the volume of various containers. A...
Programming Language C++ Task 1: Write a program to calculate the volume of various containers. A base class, Cylinder, will be created, with its derived classes, also called child classes or sub-classes. First, create a parent class, Cylinder. Create a constant for pi since you will need this for any non-square containers. Use protected for the members. Finally, create a public function that sets the volume. // The formula is: V = pi * (r^2) * h Task 2: Create...
Complete the following assignment in C programming language. Get the user’s first name and store it...
Complete the following assignment in C programming language. Get the user’s first name and store it to a char array Declare a character array to hold at least 20 characters. Ask for the user’s first name and store the name into your char array. Hint: Use %s for scanf. %s will only scan one word and cannot scan a name with spaces. Get 3 exam scores from the user: Declare an array of 3 integers Assume the scores are out...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT