Code tính cước truy cập Internet này đúng hay chưa?

tinh cuoc truy cap internet
dua vao gio bat dau va ket thuc truy cap
tu 7-17 gio 400d/phut dc giam 10% neu truy cap >6h
tu 17-24 gio 350d/phut dc giam 12% neu truy cap >4h
tu 0-7 gio 300d/phut dc giam 15% neu truy cap >7h

#include<iostream>
using namespace std;
int main(){
	long start,end;
	long tien1,tien2,tien3;
	long accesstime;
	float tong=0;
	cout<<"gio bat dau la: ";
	cin>>start;
	cout<<"gio ket thuc la: ";
	cin>>end;
	accesstime=end-start;
	cout<<"thoi gian truy cap = "<<accesstime<<endl;
	if(start>=0&&end<=24){
		if(start>0&&end<=7){
			tien1=300;
			tong=accesstime*tien1;
			if(accesstime>7){
				tong=tong-(tong*0.15);
			}
			cout<<"1 "<<tong<<endl;
		}
		else if(end>7){
			tien1=300;
			tong=accesstime*tien1;
			if(accesstime>7){
				tong=tong-(tong*0.15);
			}
			cout<<"1 "<<tong<<endl;
		}
		if(end>7&&end<=17){
			tien2=400;
			tong=tong+(accesstime*tien2);
			if(accesstime>6){
				tong=tong-(tong*0.1);
			}
			cout<<"2 "<<tong<<endl;
			
		}
		else if(end>=17){
			tien2=400;
			tong=tong+(accesstime*tien2);
			if(accesstime>6){
				tong=tong-(tong*0.1);
			}
			cout<<"2 "<<tong<<endl;
				
			}
		if(end>17&&end<=24){
			tien3=350;
			tong=tong+(accesstime*tien3);
			if(accesstime>4){
				tong=tong-(tong*0.12);
			}
			cout<<"3 "<<tong;
		}
	}
	return 0;
}

Chạy thử là biết, sao phải hỏi nữa!?

3 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?