#include <conio.h>
using namespace std;
class Lucky
{
private :
long num,hasil_awal,hasil,hasil_akhir,hasil_mula,hasil_nyata,hasil_copy;
public :
void Input();
void Proses();
void Output();
Lucky();
};
void Lucky :: Input()
{
cout<<"Masukan nilai : ";
cin>>num;
}
void Lucky :: Proses()
{
while (num != 0)
{
hasil_awal=num%10;
hasil=hasil+hasil_awal;
num=num/10;
}
while (hasil != 0)
{
hasil_mula=hasil%10;
hasil_akhir=hasil_akhir+hasil_mula;
hasil=hasil/10;
}
if (hasil_akhir >= 10)
{
while (hasil_akhir != 0)
{
hasil_copy=hasil_akhir%10;
hasil_nyata=hasil_nyata+hasil_copy;
hasil_akhir=hasil_akhir/10;
}
cout<<"Your lucky number is : "<
else
cout<<"Your lucky number is : "<
Lucky::Lucky()
{
hasil=0;
hasil_akhir=0;
hasil_nyata=0;
}
int main()
{
Lucky akses;
akses.Input();
akses.Proses();
getch();
}
No comments:
Post a Comment