Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.8 kB
1
Indexable
#include<stdio.h>
#include<conio.h>
#include<Windows.h>
#define giacodinh 30000
#define giobatdaukhunggiovang 8
#define gioketthuckhunggiovang 17
#define giomocua 8
#define giodongcua 24
#define discount_giovang 0.9
#define discount_thuenhieuhon3h 0.7

int main()
{
	int giobatdau, phutbatdau;
	int gioketthuc, phutketthuc;

	printf("\nnnhap vao gio khach bat dau thue phong: ");
	scanf_s("%dh%d", &giobatdau, &phutbatdau);

	printf("\nnnhap vao gio khach tra phong: ");
	scanf_s("%dh%d", &gioketthuc, &phutketthuc);

	float giobatdauthue = giobatdau + (float)phutbatdau / 60;
	float giotraphong = gioketthuc + (float)phutketthuc / 60;

	float sogiokhachthue = giotraphong - giobatdauthue;

	if (giobatdau >= giomocua && giobatdau < gioketthuc && gioketthuc <= giodongcua)
	{
		float giatong;

		if (giobatdau <= gioketthuckhunggiovang && giobatdau >= giobatdaukhunggiovang)
		{
			if (giotraphong <= gioketthuckhunggiovang) 
			{
				if (sogiokhachthue <= 3)
				{
					giatong = (sogiokhachthue * giacodinh) * discount_giovang;
					
				}
				else
				{
					giatong = (3 * giacodinh + (sogiokhachthue - 3) * discount_thuenhieuhon3h) * discount_giovang;			
				}
			}
			else if (giotraphong > gioketthuckhunggiovang) 
			{
				giatong = (3 * giacodinh + (gioketthuckhunggiovang - giobatdaukhunggiovang - 3) * discount_thuenhieuhon3h) * discount_giovang + (giotraphong-gioketthuckhunggiovang) * discount_thuenhieuhon3h;
			}
		}
		else
		{
			if (sogiokhachthue <= 3)
			{
				giatong = (sogiokhachthue * giacodinh);
			}
			else
			{
				giatong = (3 * giacodinh) + (sogiokhachthue - 3) * discount_thuenhieuhon3h;
			}
		}
		printf("\ntong so tien khach phai tra la: %f ", giatong);
	}
	else
	{
		printf("vui long chi don khach vao gio qui dinh!");
	}

	return 0;
}