السلام عليكم
قمت بحل هذا البرنامج بلغة السي بلس بلس .. ولكن انا لست مقتنعه بحلي .. حيث اريد برنامج يقوم بعمل زيادة تلقائية للوقت ساعة واحدة كل 60 دقيقة ... وهناك مشكلة صعبه لا اعلم هل يطلبها البرنامج هنا او هي اضافه مني
اذا وصل عداد الساعات الى اكثر من 23 يبدا يعيد الحساب من الساعة 00 حتى يكون حساب التكلفة كامل .. ولكن بعض الاشخاص اشارولي ان البرنامج الذي قمت بكتابته صحيح ولكني لست مقتنعه بذلك
هذا السؤالWrite a program that computes the cost of a long distance call. The cost of the call is computed according to the following rate schedule:
a. Any call started between 8:00 and 18:00 will be billed at SR 0.5 per minute.
b. Any call starting before 8:00 or after 18:00 will be charged at SR0.4 per minute.
The input will consist of: the time the call was started and the length of the call in minutes. The output will be the total cost of the call.
وهنا حلي
#include <iostream>
using namespace std;
int main()
{
float TotalCost=0,call=0;
float time, cost=0,length=0.0;
while(time<0||time>23)
{
cout<<"Please Enter the Time of call:";
cin>>time;
}
cout<<"Enter the length of the call:";
cin>>length;
if(time>=8&&time<=18)cost=length* 0.5;
else cost=length*0.4;
cout<<"\nThe cost of call is:"<<cost<<endl;
return 0;
}