السلام عليكم
ابي المساعده بتصحيح الكود إذا كانت المدخلات للدقائق والثواني 60 او اكثر مايغير لي شي ابدا بالخانات الثانيه
اعتقد الخطأ عندي بالشرط ما اعرف ايش المشكله بالضبط وهذا الكود
//Date:1-12-2009
//perposs:clss of Time.
//file name: Homework4 in (( c:Windows\System32\Homework4.cpp )).
//Auther:hanonah
#include<iostream>
#include<iomanip>
using namespace std;
class Time
{
private:
int Hours;
int Minutes;
int Seconds;
public:
Time():Hours(0),Minutes(0),Seconds(0)
{/* Empty body*/}
Time(int H , int M , int S);
void Show();
void Mang(Time);
};
//function prototype
Time :: Time(int H , int M , int S)
{ Hours=H;
Minutes=M;
Seconds=S;
}
void Time::Show()
{
cout<<Hours<<":"<<Minutes<<":"<<Seconds<<(Hours < 12 ? " AM" : " PM");
}
void Time::Mang(Time T1)
{
if(T1.Seconds>=60)
{ T1.Seconds-=60;
T1.Minutes++;}
if(T1.Minutes>=60)
{T1.Minutes-=60;
T1.Minutes++;}
}
void main()
{
float H,M,S;
Time T0,T2;
cout<<"Enter the Hours note that it is in 24 module: ";
cin>>H;
while(H>24)
{cout<<"You must inter the right houre"<<'\n';
cout<<"Enter the Hours note that it is in 24 module: ";
cin>>H;}
cout<<"Enter the Minutes: ";
cin>>M;
cout<<"Enter the Seconds: ";
cin>>S;
Time T1(H,M,S);
cout<<'\n';
cout<<'\n';
cout<<"The Time is"<<'\n'<<'\n';
T2.Mang(T1);
cout<<setw(20);T1.Show();
cout<<'\n';
cout<<'\n';
cout<<setw(30)<<"by hanonah ^_^";
cout<<'\n';
cout<<'\n';
}وشكرا ,,
