انا حليت السوال وطالع لى الاوت بوت غير صحيح رياضيا وكامن لازم جمله شرط ولا عرفت احطها
وهذا السوال
:
Create a class called Time that includes three pieces of information as data members{an hour (type int), minute (type int) and second (type int)}.
• Provide a member function void set ( ) that set the three data members by user input,ensure that the value provided by user for the seconds and minutes in the range 0-59, and hours in range 0-23; if it is not, set the value to 0.For that Provide three member functions:
VoidValidateoHour(int);
VoidValidateMinute(int);
VoidValidateSecond (int);
• Provide a member function DisplayTimeInSeconds that output the time in seconds.
write a program that uses Time class to shows following sample.
ويفترض ان الاوت بوت يكون كذا
Sample output :
Enter The Time
Hours :2
Minutes :40
Seconds :30
The Time Is : 9630 Second
وهذى مجاولتى فى حل الكود
#include <iostream>
using namespace std;
class Time
{public:
void ValidateoHour(int h )
{
cout<<"Hours : ";
cin>>h;
}
void ValidateMinute(int m)
{cout<<"Minutes : ";
cin>>m;
}
void ValidateSecond (int s)
{
cout<<"Seconds : ";
cin>>s;
}};
void DisplayTimeInSeconds(int h,int m,int s)
{
cout<<(h*3600)+(m*60)+s;
}
int main()
{int a,b,h,m,s;
Time ti;
cout<<"Enter The Time\n";
ti.ValidateoHour(h);
ti.ValidateMinute(m);
ti.ValidateSecond (s);
cout<<"The Time Is : \n";
DisplayTimeInSeconds(h,m,s);
cout<<" Second";
return 0;
}
والمشكله عندى مثل ماقلت انى ماعرف وين احط جمله الشرط كذلك تحويل الى السكند يطلع الرقم خطا
