الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلة في عداد الوقت

مغلق
بدأه a7la_lolly في 10 أبريل 2006 · 4 رد · 421 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

قمت بحل هذا البرنامج بلغة السي بلس بلس .. ولكن انا لست مقتنعه بحلي .. حيث اريد برنامج يقوم بعمل زيادة تلقائية للوقت ساعة واحدة كل 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;

}

#2

لا ارى اي عداد لزيادة الوقت,

البرنامج المكتوب عباره عن برنامج يسأل المستخدم لادخال وقت و مدة المكالمه و على اساسها يعطي التكلفه

سؤالك غير مفهوم !!!

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#3

#include <iostream>

using namespace std;

int check(int time)

{

while(time>=24)

time-=24;

return time;

}

int main()

{

float TotalCost=0,call=0;

float time, cost=0,length=0.0;

while(time<0)

{

cout<<"Please Enter the Time of call:";

cin>>time;

}

if(time>=24)

time=check(time);

cout<<time<<endl;

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;

هذا البرنامج هو جواب للسؤال

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#4

اسف لم انتبه ان ال time عندك هو float

فقط غيري ال الفنكشن chck ال

float check(float time)

{

while(time>=24)

time-=24;

return time

ENG. IMAD, Programing is a way of life, It's in the air, we breath It's pumps through our veines, Without it, we soon crumble to dust

#5

الف الف شكر ... فتح الله على عقلك وقلبك ..

هذا الموضوع مغلق.

مواضيع مشابهة